On Tuesday, January 21, 2014 6:25:02 AM UTC+8, Sergey Didenko wrote:
>
> Hi Xfeep,
>
> What are the good ways to handle some heavy Clojure calculations when 
> using nginx-clojure?
>

Do you mean every request will cost too much time ?  If time cost is mainly 
caused by IO blocking,  java thread pool can be used to resolve this 
problem. 

Otherwise you must add more  computers or use more fast hardware to handle 
those pure  CPU concentrated tasks.
 

> Under nginx model it's bad to block other incoming requests by holding a 
> working thread for too long, right?
>

Yes. Typically  the nginx worker processes won't be too many  and maybe the 
same number of your cpu cores. 
If you can not reduce single reponse time,  all worker will be blocked by 
those slow tasks.


> So is it better to route complex job to http-kit? Or to use some kind of 
> queue? Or may be to use this nginx-clojure JVM pool that is off by default?
>


Suppose your time cost is mainly caused by IO blocking, java thread pool  
can be used by two ways :

(1)  use *pcall* , *pvalue* etc. provided by clojure to execute your tasks 
parallel  to reduce single request-response time.
OR
(2)  with nginx-clojure just simply set jvm_workers to some medium  number 
eg 100, or bigger number if you get more memory. This thread pool will make 
nginx workers not blocked until all threads are exhausted.

When jvm_workers > 0,  there's additional cost to one transfer  event flag  
by  pipe. But this cost can be ignored for your slow response and this cost 
will be lower than using nginx as a proxy to  pass requests to backend java 
server.

In the future release of Nginx-Clojure,  synchronized non-blocking IO APIs  
will be provided.  I think those synchronized non-blocking APIs will 
simpilfy to handle some IO blocked tasks.

By that time jvm_workers maybe no need to be > 0 .
 

>
> On Wed, Jan 15, 2014 at 3:18 PM, Xfeep Zhang <easy...@163.com<javascript:>
> > wrote:
>
>>
>>
>> On Wednesday, January 15, 2014 12:39:57 PM UTC+8, Roberto De Ioris wrote:
>>
>>>
>>> i strongly suggest you to avoid the "performance" as a selling point, 
>>> your 
>>> project is cool but not for performance (and you are using a pipe to 
>>> transfer requests data from nginx to the jvm so there ipc in place too, 
>>> even if you can improve things using OS-specific syscall like splice). 
>>>
>>  
>> Although I have make it clear in the nginx english mail list,  people 
>> joined clojure group may still misunderstand.
>>
>> So please forgive me repeating the message here.
>>
>> In the nginx english mail list , I have said :
>>
>> " With the default setting pipe is not used.
>>
>> Pipe is only used for enable jvm thread pool mode only when jvm_workers > 
>> 0 (jvm_workers default = 0).
>>
>> Further more pipe is never used to transfer the whole request or response 
>> message.
>>
>> When under jvm thread pool mode, pipe is only used to transfer a event 
>> flag (only one pointer size)。"
>>  
>>
>>>
>>> -- 
>>> Roberto De Ioris 
>>> http://unbit.it 
>>>
>>  -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com<javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to