You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These tips are really useful. Most of them are from real users. Thanks [Rickr Nook](https://github.com/rickr-nook) who give us some useful tips.
93
93
94
94
1. The number of embed JVMs is the same with Nginx `worker_processes`, so if `worker_processes` > 1 we maybe need [nginx-clojure broadcast API][], shared memory (e.g [SharedHashMap/Chronicle-Map][]) or
95
-
even external service(e.g. redis, database) to coordinate the state.
95
+
even external service(e.g. redis, database) to coordinate the state or use cookie based session store to manage session information, e.g. [ring.middleware.session.cookie/cookie-store](https://github.com/mmcgrana/ring/wiki/Sessions).
96
96
1. When importing Swing We Must specifiy `jvm_options "-Djava.awt.headless=true"` , otherwise the nginx will hang.
97
97
1. By adding the location of your clojure source files to the classpath,then just issue "nginx -s reload" and changes to the sources get picked up!
98
98
1. You can remove clojure-1.5.1.jar from class path and point at your "lein uberjar" to pick up a different version of clojure.
@@ -665,7 +665,7 @@ e.g.
665
665
}
666
666
```
667
667
668
-
2.7 Niginx Header Filter
668
+
2.7 Nginx Header Filter
669
669
-----------------
670
670
671
671
We can use Nginx Header Filter written by Java/Clojure/Groovy to do some useful things, e.g.
Copy file name to clipboardExpand all lines: Configuration.md.html
+2-2
Original file line number
Diff line number
Diff line change
@@ -90,7 +90,7 @@ <h3>
90
90
91
91
<ol>
92
92
<li>The number of embed JVMs is the same with Nginx <code>worker_processes</code>, so if <code>worker_processes</code> > 1 we maybe need <ahref="https://github.com/nginx-clojure/nginx-clojure/issues/38">nginx-clojure broadcast API</a>, shared memory (e.g <ahref="https://github.com/OpenHFT/Chronicle-Map">SharedHashMap/Chronicle-Map</a>) or
93
-
even external service(e.g. redis, database) to coordinate the state.</li>
93
+
even external service(e.g. redis, database) to coordinate the state or use cookie based session store to manage session information, e.g. <ahref="https://github.com/mmcgrana/ring/wiki/Sessions">ring.middleware.session.cookie/cookie-store</a>.</li>
94
94
<li>When importing Swing We Must specifiy <code>jvm_options "-Djava.awt.headless=true"</code> , otherwise the nginx will hang.</li>
95
95
<li>By adding the location of your clojure source files to the classpath,then just issue "nginx -s reload" and changes to the sources get picked up!</li>
96
96
<li>You can remove clojure-1.5.1.jar from class path and point at your "lein uberjar" to pick up a different version of clojure. </li>
Copy file name to clipboardExpand all lines: More.md
+30
Original file line number
Diff line number
Diff line change
@@ -738,6 +738,16 @@ in nginx.conf
738
738
}
739
739
```
740
740
741
+
## Session Management
742
+
743
+
If `worker_processes` > 1 there will be more than one jvm instances viz. more tomcat instances so to get synchronized session information we can not use the default tomcat session manger.
744
+
Instead we may consider to use either of
745
+
746
+
1. Cookie based Session Store viz. storing all session attribute information into cookies.
747
+
1. Shared HashMap among processes in the same machine ,e.g. [Chronicle Map](https://github.com/OpenHFT/Chronicle-Map)
748
+
1. External Session Store, e.g. Redis / MySQL / Memcached Session Store
[2.2 Initialization Handler for nginx worker]: configuration.html#user-content-22-initialization-handler-for-nginx-worker
791
801
802
+
3.11 More about Nginx Worker Process
803
+
-----------------
804
+
The number of Nginx worker processes can be configured by nginx directive [worker_processes](http://nginx.org/en/docs/ngx_core_module.html#worker_processes).
805
+
e.g. We use8 Nginx worker processes:
806
+
807
+
```nginx
808
+
worker_processes 8;
809
+
```
810
+
811
+
Because a JVM instance will be embeded into per Nginx worker process so if there are more than one Nginx worker prcocesses there will be more than one JVM instances.
812
+
So if we want to get synchronized session information we can not use the default tomcat session manger. Instead we may consider to use either of
813
+
814
+
1. Cookie based Session Store viz. storing all session attribute information into cookies.
815
+
1. Shared HashMap among processes in the same machine ,e.g. [Chronicle Map](https://github.com/OpenHFT/Chronicle-Map)
816
+
1. External Session Store, e.g. Redis / MySQL / Memcached Session Store
817
+
818
+
When there are more than one Nginx worker prcocesses sub/pub services also need to be taken care of. Subscribers may connect to JVM instances which maybe are different
819
+
with the JVM instance which the publisher send message to. So we need to use [broadcast API](more.html#35-subpub--broadcast-event) from nginx-clojure
820
+
and broadcast message to all Nginx worker prcocesses.
<p>If <code>worker_processes</code> > 1 there will be more than one jvm instances viz. more tomcat instances so to get synchronized session information we can not use the default tomcat session manger.
721
+
Instead we may consider to use either of</p>
722
+
723
+
<ol>
724
+
<li>Cookie based Session Store viz. storing all session attribute information into cookies.</li>
725
+
<li>Shared HashMap among processes in the same machine ,e.g. <ahref="https://github.com/OpenHFT/Chronicle-Map">Chronicle Map</a>
726
+
</li>
727
+
<li>External Session Store, e.g. Redis / MySQL / Memcached Session Store</li>
<p><code>gzip</code> can also appear at http, server blocks. More details can be found <ahref="http://nginx.org/en/docs/http/ngx_http_gzip_module.html">HERE</a></p>
771
+
772
+
<h2>
773
+
<aid="user-content-311-more-about-nginx-worker-process" class="anchor" href="#311-more-about-nginx-worker-process" aria-hidden="true"><spanclass="octicon octicon-link"></span></a>3.11 More about Nginx Worker Process</h2>
774
+
775
+
<p>The number of Nginx worker processes can be configured by nginx directive <ahref="http://nginx.org/en/docs/ngx_core_module.html#worker_processes">worker_processes</a>.
<p>Because a JVM instance will be embeded into per Nginx worker process so if there are more than one Nginx worker prcocesses there will be more than one JVM instances.
781
+
So if we want to get synchronized session information we can not use the default tomcat session manger. Instead we may consider to use either of </p>
782
+
783
+
<ol>
784
+
<li>Cookie based Session Store viz. storing all session attribute information into cookies.</li>
785
+
<li>Shared HashMap among processes in the same machine ,e.g. <ahref="https://github.com/OpenHFT/Chronicle-Map">Chronicle Map</a>
786
+
</li>
787
+
<li>External Session Store, e.g. Redis / MySQL / Memcached Session Store</li>
788
+
</ol>
789
+
790
+
<p>When there are more than one Nginx worker prcocesses sub/pub services also need to be taken care of. Subscribers may connect to JVM instances which maybe are different
791
+
with the JVM instance which the publisher send message to. So we need to use <ahref="more.html#35-subpub--broadcast-event">broadcast API</a> from nginx-clojure
792
+
and broadcast message to all Nginx worker prcocesses.</p>
<li><ahref="embed.html"><spanclass="glyphicon glyphicon-gift"></span> Embedding Nginx-Clojure into A standard App</a></li>
80
79
<li><ahref="more.html#34-server-channel-for-long-polling--server-sent-events-sse"><spanclass="glyphicon glyphicon-envelope"></span> Server Channel for Long Polling & Server Sent Events</a></li>
81
80
<li><ahref="more.html#35-subpub--broadcast-event"><spanclass="glyphicon glyphicon-signal"></span> Sub/Pub services with Broadcast Events</a></li>
<li><ahref="more.html#38--sever-side-websocket"><spanclass="glyphicon glyphicon-th-list"></span> Sever Side WebSocket</a></li>
85
84
<li><ahref="more.html#39--java-standard-restful-web-services-with-jersey"><spanclass="glyphicon glyphicon-th-list"></span> Java standard RESTful web services with Jersey</a></li>
<li><ahref="more.html#311-more-about-nginx-worker-process"><spanclass="glyphicon glyphicon-th-list"></span> More about Nginx Worker Process</a></li>
87
87
<li><ahref="more.html"><spanclass="glyphicon glyphicon-th-list"></span> More about Nginx-Clojure</a></li>
88
88
</ul>
89
89
</div>
@@ -187,7 +187,7 @@ <h3>
187
187
188
188
<ol>
189
189
<li>The number of embed JVMs is the same with Nginx <code>worker_processes</code>, so if <code>worker_processes</code> > 1 we maybe need <ahref="https://github.com/nginx-clojure/nginx-clojure/issues/38">nginx-clojure broadcast API</a>, shared memory (e.g <ahref="https://github.com/OpenHFT/Chronicle-Map">SharedHashMap/Chronicle-Map</a>) or
190
-
even external service(e.g. redis, database) to coordinate the state.</li>
190
+
even external service(e.g. redis, database) to coordinate the state or use cookie based session store to manage session information, e.g. <ahref="https://github.com/mmcgrana/ring/wiki/Sessions">ring.middleware.session.cookie/cookie-store</a>.</li>
191
191
<li>When importing Swing We Must specifiy <code>jvm_options "-Djava.awt.headless=true"</code> , otherwise the nginx will hang.</li>
192
192
<li>By adding the location of your clojure source files to the classpath,then just issue "nginx -s reload" and changes to the sources get picked up!</li>
193
193
<li>You can remove clojure-1.5.1.jar from class path and point at your "lein uberjar" to pick up a different version of clojure. </li>
<li><ahref="embed.html"><spanclass="glyphicon glyphicon-gift"></span> Embedding Nginx-Clojure into A standard App</a></li>
80
79
<li><ahref="more.html#34-server-channel-for-long-polling--server-sent-events-sse"><spanclass="glyphicon glyphicon-envelope"></span> Server Channel for Long Polling & Server Sent Events</a></li>
81
80
<li><ahref="more.html#35-subpub--broadcast-event"><spanclass="glyphicon glyphicon-signal"></span> Sub/Pub services with Broadcast Events</a></li>
<li><ahref="more.html#38--sever-side-websocket"><spanclass="glyphicon glyphicon-th-list"></span> Sever Side WebSocket</a></li>
85
84
<li><ahref="more.html#39--java-standard-restful-web-services-with-jersey"><spanclass="glyphicon glyphicon-th-list"></span> Java standard RESTful web services with Jersey</a></li>
0 commit comments