[Libwebsockets] Problem of multiple persistent WebSocket connections

Andy Green andy at warmcat.com
Tue Sep 19 09:49:04 CEST 2017



On 09/19/2017 03:32 PM, Zhang, Luis (Thin Client R&D) wrote:
> Attached is the log file.
> 
> There are a lot of TIMEDOUT messages likes below. I modified the timeout from 5 seconds to 15 seconds, the issue occurred too.
> 
> [2017/09/19 15:16:22:0048] NOTICE: wsi 0x7fd624162660: TIMEDOUT WAITING on 3 (did hdr 0, ah (nil), wl 611, pfd events 0)
> [2017/09/19 15:16:22:0048] NOTICE: wsi 0x7fd624142bb0: TIMEDOUT WAITING on 3 (did hdr 0, ah (nil), wl 611, pfd events 0)
> [2017/09/19 15:16:22:0048] NOTICE: wsi 0x7fd624142900: TIMEDOUT WAITING on 3 (did hdr 0, ah (nil), wl 611, pfd events 0)
> [2017/09/19 15:16:22:0048] NOTICE: wsi 0x7fd624142650: TIMEDOUT WAITING on 3 (did hdr 0, ah (nil), wl 611, pfd events 0)
> [2017/09/19 15:16:22:0048] NOTICE: wsi 0x7fd6241303a0: TIMEDOUT WAITING on 3 (did hdr 0, ah (nil), wl 611, pfd events 0)
> [2017/09/19 15:16:22:0048] NOTICE: wsi 0x7fd6241300f0: TIMEDOUT WAITING on 3 (did hdr 0, ah (nil), wl 611, pfd events 0)
> [2017/09/19 15:16:22:0048] NOTICE: wsi 0x7fd62412fe40: TIMEDOUT WAITING on 3 (did hdr 0, ah (nil), wl 611, pfd events 0)

Timeout reason 3 is "PENDING_TIMEOUT_ESTABLISH_WITH_SERVER"... this 
starts when we accept the incoming connection and is cleared when we 
deal with his headers.

Since an ah is required to deal with the headers, I guess these are 
getting tied up.

When you create the context, what do you set info.max_http_header_pool 
to?  The default is just 4... if you have 100,000 connections you 
probably want to scale this up to 256 or more.  This sets how many 
connections can simultaneously process http headers.

-Andy

> Best Regards,
> Luis
> 
> 
> -----Original Message-----
> From: Libwebsockets [mailto:libwebsockets-bounces at ml.libwebsockets.org] On Behalf Of Zhang, Luis (Thin Client R&D)
> Sent: Monday, September 18, 2017 9:47
> To: Andy Green <andy at warmcat.com>; libwebsockets at ml.libwebsockets.org
> Subject: Re: [Libwebsockets] Problem of multiple persistent WebSocket connections
> 
> I will reproduce it and get more detailed logs later.
> 
> Best Regards,
> Luis
> 
> 
> -----Original Message-----
> From: Andy Green [mailto:andy at warmcat.com]
> Sent: Monday, September 18, 2017 9:33
> To: Zhang, Luis (Thin Client R&D) <xiaolu.zhang at hp.com>; libwebsockets at ml.libwebsockets.org
> Subject: RE: [Libwebsockets] Problem of multiple persistent WebSocket connections
> 
> 
> 
> On September 18, 2017 9:12:35 AM GMT+08:00, "Zhang, Luis (Thin Client R&D)" <xiaolu.zhang at hp.com> wrote:
>> Thanks.
>>
>> The platform is Debian 8.5 and I used libuv.
> 
> OK... so what happens when it seems to go wrong?
> 
> Can you reproduce this with the libuv test server?  Can you let me know how to reproduce?
> 
> LWS_WITH_STATS is on master, it logs a bunch of interesting stats every 10s.
> 
> -Andy
> 
>> Best Regards,
>> Luis
>>
>>
>> -----Original Message-----
>> From: Andy Green [mailto:andy at warmcat.com]
>> Sent: Monday, September 18, 2017 9:11
>> To: Zhang, Luis (Thin Client R&D) <xiaolu.zhang at hp.com>;
>> libwebsockets at ml.libwebsockets.org
>> Subject: Re: [Libwebsockets] Problem of multiple persistent WebSocket
>> connections
>>
>>
>>
>> On 09/18/2017 09:07 AM, Andy Green wrote:
>>>
>>>
>>> On 09/18/2017 08:51 AM, Zhang, Luis (Thin Client R&D) wrote:
>>>> I'm working on developing a WebSocket Server that supports for
>>>> multiple persistent WebSocket connections. Our goal is supporting
>> for
>>>> 100K connections concurrently. As mentioned in
>>>> https://libwebsockets.org/ that per thread can support 250K
>>>> connections. So I think that there is no problem for supporting 100K
>>
>>>> persistent WebSocket connections. And I verified it with v2.0.0, it
>>>> works well.
>>>>
>>>> But, when I upgraded the libwebsockets lib to v2.1, the server
>> cannot
>>>> accepted so many connections. It only can accepted about 40K
>>>> connections. When about 40K connections were established, I cannot
>>>> establish websocket connection any more. I also test it with v2.2
>> and
>>>> v2.3, I got the same result.
>>>>
>>>> The test environment of all test case are same, just the version of
>>>> libwesocket lib are different.
>>>
>>>    - what is the platform?
>>>
>>>    - what *exactly* happens when you "cannot establish websocket
>>> connection any more"?  Logs?
>>
>> ... and...
>>
>>   - what event loop?  Default, using libuv / ev / event?
>>
>>>
>>> There's no intention to reduce the max clients the server can serve,
>>> on the contrary...
>>>
>>> -Andy
>>>
>>>> Any thoughts? Thank you.
>>>>
>>>> Best Regards,
>>>>
>>>> Luis
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Libwebsockets mailing list
>>>> Libwebsockets at ml.libwebsockets.org
>>>> https://libwebsockets.org/mailman/listinfo/libwebsockets
>>>>
>>> _______________________________________________
>>> Libwebsockets mailing list
>>> Libwebsockets at ml.libwebsockets.org
>>> https://libwebsockets.org/mailman/listinfo/libwebsockets
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets
> 



More information about the Libwebsockets mailing list