[Libwebsockets] libwebsockets : Query related to max connections supported, I/O mechanism and message posting

Andy Green andy at warmcat.com
Thu Dec 5 14:36:19 CET 2013

ayush jain <jain.ayush09 at gmail.com> wrote:
>Hello everyone,
>It's been a week or so I started up researching on websockets and I
>up here as I found a lot of interesting things about libwebsockets.
>I was seeking some help regarding some aspects about the library in
>of performance, I/O mechanism and message posting.
>1) Is there any kind of bottleneck or performance issues (if it has
>tested) in case I wish to integrate the same to a server supporting
>200k simultaneous tcp/tls connections?

Well something will always limit performance.  Lws should give very good performance for one process context it's running in.  Having a multicore cpu won't help that one process much.

So if you want strong performance on huge numbers of sockets you should think about spreading it across multiple instances that have some kind of ipc.

>2) I see there are 2 ways related to internal/external I/O mechanism
>integration. But I see the API (libwebsocket_service_fd) takes in
>structure as argument, Can I use the libwebsocket library with my
>Epoll implementation when I use external I/O other than POLL, as there
>would be lot of inactve FD's in my case? Or I need to stick to POLL? I
>don't have poll mechanism in my server.

The lib either uses internal poll loop or interfaces to some kind of external polling loop with an api that uses pollfd semantics.

There's no requirement the external loop actually is using poll(), so long as you set and interpret the pollfd api parts appropriately that's enough.

>3) When we say libwebsocket is single threaded, Do we mean that for all
>send and receive using the library, I need to make sure (in case am
>implementing server) that the call to libwebsocket_service_fd() and any
>message posting by requesting callbacks happens in 1 thread? I mean
>whatever response my server needs to post back to client after
>of request, How am I going to save or store that data when I get a
>once my server side socket is writeable?

What it means is that all your interactions with lws must occur from the user callback code.

You can allocate per connection user storage, you would do something like manage a per-connection fifo in there and spill it on the writable callback while it still had something waiting to go.


>I know am asking too much of information here, but would really
>if can respond to the same. Looking forward to your response.
>Thanks in advance.
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org

Sent from my Android device with K-9 Mail. Please excuse my brevity.

More information about the Libwebsockets mailing list