tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Grigorov <mgrigo...@apache.org>
Subject Re: websockets questions
Date Thu, 04 Jul 2013 15:05:00 GMT
On Thu, Jul 4, 2013 at 5:52 PM, André Warnier <aw@ice-sa.com> wrote:

> Mark Thomas wrote:
>
>> On 04/07/2013 10:17, André Warnier wrote:
>>
>>> To me that means that at some point, there must be on the server side a
>>> process or thread which is dedicated to this websocket client for as
>>> long as it takes, and this process/thread in the meantime is no longer
>>> available to process other HTTP requests.
>>> (That's because the basic idea is that the "websocket application" on
>>> the server side can keep sending messages asynchronously to the client -
>>> and vice-versa - so I don't see how this can work with different
>>> threads/processes on the server; but I'm not that smart, so it may be
>>> that the implementation is smarter).
>>> For that same reason, it would seem that the very concept of
>>> "load-balancing" must be suspended once the websocket connection is
>>> established.
>>>
>>
>> The connection has to be kept open but you can use non-blocking IO to
>> only allocate a thread to process data when there is data to process.
>>
>> The exact behaviour varies between Tomcat 7 and Tomcat 8.
>>
>> BIO 7 & 8 - 1 thread per connections, blocking IO, doesn't scale
>>
>> NIO / APR 7 - 1 thread per currently processed frame, non-blocking
>> between frames, scales better
>>
>> NIO / APR 8 - threads only allocated where there is data to process,
>> scales best
>>
>
> "data to process" meaning an entire websocket "message" I suppose ?
>
>
>> Note that JSR356 allows blocking writes. If the client or the server opt
>> to send data using a blocking write then that will use a thread until
>> the write completes.
>>
>> Load-balancers should cope perfectly happily with this.
>>
>> There is no upgrade or WebSocket support in AJP yet.
>>
>>
> Thanks for these precisions.
>
> Another question while we're at it :
> As I understand from the specs/docs, there are 2 kinds of messages : text
> or "blob".
> And I found that there are 2 ways of reading that data, corresponding to
> these 2 types of messages.
> However, I do not find anywhere a function or method or call which would
> allow for example the server-side application to find out in advance if the
> data currently available for reading is one or the other type.  Did I miss
> that somewhere, or do I misunderstand the specs/docs ?
>

The application is being notified. The container calls either
onMessage(String/CharBuffer) or onMessage(byte[]/ByteBuffer) on the
endpoint (or whatever is the exact API)


>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.**apache.org<users-unsubscribe@tomcat.apache.org>
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message