Concurrent requests to the same function

160 views
Skip to first unread message

Pavlos Parissis

unread,
Sep 10, 2014, 6:19:24 PM9/10/14
to zer...@googlegroups.com
Hi,

Just few hours ago a friend suggested to have a look at zeroRPC for my little project and wanted to know if zeroRPC will serialize concurrent requests from multiple clients to the same function.

I need this because the function will fetch data from DB, process them and dump them in a file which is being read by other process.


Thanks,
Pavlos

 

François-Xavier Bourlet

unread,
Sep 10, 2014, 6:49:22 PM9/10/14
to zer...@googlegroups.com
Hi,

If everything works as intended, it wont serialize anything:

zerorpc achieves IO multiplexing via gevent. Your database library
hopefully is compatible with gevent, thus you get maximum concurrency.

You can limit the global concurrency of zerorpc.Server via the
pool_size parameter. So you could of course set pool_size=1 to
serialize any function. But that would limit all concurrent call to
any other function. You could use a gevent mutex, semaphore, a
gevent.pool of 1, or a queue to serialize the access to your file.

My advice: If you want to serialize the whole function, use a mutex,
if you want to serialize access to the file, use queue and a
coroutine.

Best,
fx
> --
> You received this message because you are subscribed to the Google Groups
> "zerorpc" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to zerorpc+u...@googlegroups.com.
> To post to this group, send email to zer...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/zerorpc/14657cc0-5f90-4379-a911-d2b88473b716%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Pavlos Parissis

unread,
Sep 11, 2014, 4:21:12 AM9/11/14
to zer...@googlegroups.com
On 11 September 2014 00:49, François-Xavier Bourlet <bom...@gmail.com> wrote:
Hi,

If everything works as intended, it wont serialize anything:

zerorpc achieves IO multiplexing via gevent. Your database library
hopefully is compatible with gevent, thus you get maximum concurrency.

You can limit the global concurrency of zerorpc.Server via the
pool_size parameter. So you could of course set pool_size=1 to
serialize any function. But that would limit all concurrent call to
any other function. You could use a gevent mutex, semaphore, a
gevent.pool of 1, or a queue to serialize the access to your file.

My advice: If you want to serialize the whole function, use a mutex,
if you want to serialize access to the file, use queue and a
coroutine.


Thank you very much  for this very informative answer, it is very much appreciated.

Best,
fx

On Wed, Sep 10, 2014 at 3:19 PM, Pavlos Parissis
<pavlos....@gmail.com> wrote:
> Hi,
>
> Just few hours ago a friend suggested to have a look at zeroRPC for my
> little project and wanted to know if zeroRPC will serialize concurrent
> requests from multiple clients to the same function.
>
> I need this because the function will fetch data from DB, process them and
> dump them in a file which is being read by other process.
>
>
> Thanks,
> Pavlos
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "zerorpc" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to zerorpc+u...@googlegroups.com.
> To post to this group, send email to zer...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/zerorpc/14657cc0-5f90-4379-a911-d2b88473b716%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "zerorpc" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/zerorpc/N5yWAMv9ck0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to zerorpc+u...@googlegroups.com.

To post to this group, send email to zer...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages