Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Send requests on separate thread?

Hi,

On Tue, Oct 4, 2022 at 12:29 AM Tomas Fernandez Lobbe <tflobbe@xxxxxxxxx> wrote:
> El lun, 3 oct 2022 a la(s) 14:52, Simone Bordet (sbordet@xxxxxxxxxxx) escribió:
>> When thread T1 sends a request, it acquires connection C1 and sends
>> the request bytes.
>> In order for T1 to come back and find another request queued, another
>> thread T2 must have queued it, found no connection available, and
>> initiated the opening of a second connection C2.
>
> I see. And does this happen only in the case of "open new connection"? How about cases where all the connections are in use? If the queue, for whatever reason got N requests, won't T1 try to clear them all?

When all connections are in use, you have N threads competing for the
same queue to send requests.
For HTTP1, the network latency should be enough to "break" the loop.
For HTTP2, you have N threads sending on a multiplexed connection so
ideally there will be little queuing, as every thread gets the chance
to send.

Again, for HTTP2 there could be a case where the queue is grown while
the single connection is being opened, and the connection-opening
thread will typically do the sends.
In certain cases, a sender thread may compete with the
connection-opening thread to send requests, but eventually there will
be a steady state.

>> T1 would try to acquire a connection but it cannot because C2 is not
>> opened yet, so it returns.
>
> But doesn't the "process(Connection)" method in HttpDestination continue processing requests without releasing the connection?

No, the connection is released back to the pool after every
request/response cycle finishes.

> I started looking at this chasing a "Max Requests queued per Destination" issue, which I believe was caused by Solr not aborting requests correctly (see [2] if you are interested), so at this point is just me trying to understand the code and making sure we are using it correctly.
> [2] https://issues.apache.org/jira/browse/SOLR-16229

I'll look at this and comment.

-- 
Simone Bordet
---
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless.   Victoria Livschitz


Back to the top