TsgcWebSocketHTTPServer › 이벤트 › OnHTTP2BeforeAsyncRequest
애플리케이션이 HTTP/2 요청이 스레드 풀에서 실행될지 연결 스레드에서 실행될지 선택할 수 있도록 HTTP/2 요청이 큐에 들어가기 전에 발생합니다.
property OnHTTP2BeforeAsyncRequest: TsgcWSOnBeforeHttp2AsyncRequest;
// TsgcWSOnBeforeHttp2AsyncRequest = procedure(Sender: TObject; Connection: TsgcWSConnection; const ARequestInfo: TIdHTTPRequestInfo; var Async: Boolean) of object
—
HTTP2Options.PoolOfThreads.Enabled가 True이면 서버는 HTTP/2 다중화를 활용하기 위해 수신 HTTP/2 요청을 워커 풀(HTTP2Options.Threads)에서 디스패치합니다. OnHTTP2BeforeAsyncRequest는 모든 요청이 큐에 들어가기 전에 발생합니다. 결정하려면 ARequestInfo.Document를 검사하고, 스레드 풀에서 실행하려면 Async를 True(기본값)로, 연결 스레드에서 실행하려면 False로 설정하십시오. 짧은 요청을 연결 스레드로 라우팅하면 느린 요청은 스레드화한 채로 풀 오버헤드를 피할 수 있으며, 이것이 권장되는 미세 조정 전략입니다.
procedure OnHTTP2BeforeAsyncRequest(Sender: TObject; Connection: TsgcWSConnection;
const ARequestInfo: TIdHTTPRequestInfo; var Async: Boolean);
begin
if ARequestInfo.Document = '/fast-request' then
Async := False;
end;