[zeromq-dev] how to integrate zmq to normal epoll web server

technical issue techweb2k at gmail.com
Wed Nov 17 11:30:32 CET 2010


Thank for your quick reply.
I have read the code of Mongrel2 but It's very hard to understand the
Super-Poll mechanism they used.
Would you like to give me a small example about using getsockopt(ZMQ_FD) with
example.



On Wed, Nov 17, 2010 at 2:45 PM, Martin Sustrik <sustrik at 250bpm.com> wrote:

> On 11/17/2010 05:22 AM, technical issue wrote:
>
>         I want to write a web server in C++ that use ZMQ to transfer the
>>        job to worker and receive the respone from the worker.
>>        The web server using epoll runs in a process separated from the
>>        worker process.
>>        In the web server process we have 1 main thread and two child
>>        threads.
>>        when initializing, the main thread creates two child threads:
>>        one for transferring the jobs to the PUSH queue (called C1), one
>>        for receive the response from the SUB queue (like
>>        Mongrel2),called C2.
>>        the main thread uses epoll to accept the connection from the
>>        client, parses HTTP header and then pushes the job to a queue
>>        then the C1 gets job from internal queue and push to ZMQ PUSH
>>        queue.
>>        My question is:
>>        - Is this architect OK?
>>
>
> I think so. AFAIK Mongrel2 does it the same way.
>
>
>         - Sholud I use 1 or 2 ZMQ I/O thread for C1 and C2 ?
>>
>
> 1 should be enough.
>
>
>         - Because ZMQ does not support HTTP, is there any way to
>>        integrate HTTP socket accepted from epoll into ZMQ polling?
>>
>
> Either use zmq_poll instead of EPOLL, or get the file descriptor from 0MQ
> socket useing getsockopt(ZMQ_FD) and use epoll.
>
> Martin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zeromq.org/pipermail/zeromq-dev/attachments/20101117/774dab3b/attachment.html>


More information about the zeromq-dev mailing list