From 57812004e061ae62646991607670985574a51cbd Mon Sep 17 00:00:00 2001 From: Tomasz Janczuk Date: Fri, 6 Jan 2012 11:06:24 -0800 Subject: [PATCH] fix #124: expose configuration for connection pool parameters --- src/config/iisnode_schema.xml | 2 ++ src/config/iisnode_schema_x64.xml | 2 ++ src/iisnode/cconnectionpool.cpp | 4 ++-- src/iisnode/cmoduleconfiguration.cpp | 12 ++++++++++++ src/iisnode/cmoduleconfiguration.h | 4 ++++ src/samples/configuration/readme.htm | 8 ++++++++ src/samples/configuration/web.config | 8 ++++++++ 7 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/config/iisnode_schema.xml b/src/config/iisnode_schema.xml index c78cd223..a076b336 100644 --- a/src/config/iisnode_schema.xml +++ b/src/config/iisnode_schema.xml @@ -34,6 +34,8 @@ Details at http://learn.iis.net/page.aspx/241/configuration-extensibility/ + + diff --git a/src/config/iisnode_schema_x64.xml b/src/config/iisnode_schema_x64.xml index cb4fe429..3e801528 100644 --- a/src/config/iisnode_schema_x64.xml +++ b/src/config/iisnode_schema_x64.xml @@ -34,6 +34,8 @@ Details at http://learn.iis.net/page.aspx/241/configuration-extensibility/ + + diff --git a/src/iisnode/cconnectionpool.cpp b/src/iisnode/cconnectionpool.cpp index 05ceadb7..c4ad19c0 100644 --- a/src/iisnode/cconnectionpool.cpp +++ b/src/iisnode/cconnectionpool.cpp @@ -10,8 +10,8 @@ HRESULT CConnectionPool::Initialize(IHttpContext* ctx) HRESULT hr; ErrorIf(NULL == (this->list = (PSLIST_HEADER)_aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT)), ERROR_NOT_ENOUGH_MEMORY); - this->maxPoolSize = 512; // TODO, expose configuration for this - this->maxAge = 30000; // TODO, expose configuration for this + this->maxPoolSize = CModuleConfiguration::GetMaxNamedPipeConnectionPoolSize(ctx); + this->maxAge = CModuleConfiguration::GetMaxNamedPipePooledConnectionAge(ctx); InitializeSListHead(this->list); diff --git a/src/iisnode/cmoduleconfiguration.cpp b/src/iisnode/cmoduleconfiguration.cpp index 7140a0d3..810659ea 100644 --- a/src/iisnode/cmoduleconfiguration.cpp +++ b/src/iisnode/cmoduleconfiguration.cpp @@ -444,6 +444,8 @@ HRESULT CModuleConfiguration::GetConfig(IHttpContext* context, CModuleConfigurat CheckError(GetDWORD(section, L"maxConcurrentRequestsPerProcess", &c->maxConcurrentRequestsPerProcess)); CheckError(GetDWORD(section, L"maxNamedPipeConnectionRetry", &c->maxNamedPipeConnectionRetry)); CheckError(GetDWORD(section, L"namedPipeConnectionRetryDelay", &c->namedPipeConnectionRetryDelay)); + CheckError(GetDWORD(section, L"maxNamedPipeConnectionPoolSize", &c->maxNamedPipeConnectionPoolSize)); + CheckError(GetDWORD(section, L"maxNamedPipePooledConnectionAge", &c->maxNamedPipePooledConnectionAge)); CheckError(GetDWORD(section, L"initialRequestBufferSize", &c->initialRequestBufferSize)); CheckError(GetDWORD(section, L"maxRequestBufferSize", &c->maxRequestBufferSize)); CheckError(GetDWORD(section, L"uncFileChangesPollingInterval", &c->uncFileChangesPollingInterval)); @@ -643,6 +645,16 @@ LPWSTR CModuleConfiguration::GetWatchedFiles(IHttpContext* ctx) GETCONFIG(watchedFiles) } +DWORD CModuleConfiguration::GetMaxNamedPipeConnectionPoolSize(IHttpContext* ctx) +{ + GETCONFIG(maxNamedPipeConnectionPoolSize) +} + +DWORD CModuleConfiguration::GetMaxNamedPipePooledConnectionAge(IHttpContext* ctx) +{ + GETCONFIG(maxNamedPipePooledConnectionAge) +} + HRESULT CModuleConfiguration::GetDebugPortRange(IHttpContext* ctx, DWORD* start, DWORD* end) { HRESULT hr; diff --git a/src/iisnode/cmoduleconfiguration.h b/src/iisnode/cmoduleconfiguration.h index cee885d8..05434885 100644 --- a/src/iisnode/cmoduleconfiguration.h +++ b/src/iisnode/cmoduleconfiguration.h @@ -32,6 +32,8 @@ class CModuleConfiguration : public IHttpStoredContext BOOL devErrorsEnabled; BOOL flushResponse; LPWSTR watchedFiles; + DWORD maxNamedPipeConnectionPoolSize; + DWORD maxNamedPipePooledConnectionAge; static IHttpServer* server; static HTTP_MODULE_ID moduleId; @@ -72,6 +74,8 @@ class CModuleConfiguration : public IHttpStoredContext static BOOL GetDevErrorsEnabled(IHttpContext* ctx); static BOOL GetFlushResponse(IHttpContext* ctx); static LPWSTR GetWatchedFiles(IHttpContext* ctx); + static DWORD GetMaxNamedPipeConnectionPoolSize(IHttpContext* ctx); + static DWORD GetMaxNamedPipePooledConnectionAge(IHttpContext* ctx); static HRESULT CreateNodeEnvironment(IHttpContext* ctx, DWORD debugPort, PCH namedPipe, PCH* env); diff --git a/src/samples/configuration/readme.htm b/src/samples/configuration/readme.htm index 684a17f5..3f1a3510 100644 --- a/src/samples/configuration/readme.htm +++ b/src/samples/configuration/readme.htm @@ -64,6 +64,12 @@

node process in order to send a new HTTP request * namedPipeConnectionRetryDelay - delay in milliseconds between connection retries + + * maxNamedPipeConnectionPoolSize - maximum number of named pipe connections that will be kept in a connection pool; + connection pooling helps improve the performance of applications that process a large number of short lived HTTP requests + + * maxNamedPipePooledConnectionAge - age of a pooled connection in milliseconds after which the connection is not reused for + subsequent requests * asyncCompletionThreadCount - size of the IO thread pool maintained by the IIS module to process asynchronous IO; setting it to 0 (default) results in creating one thread per each processor on the machine @@ -126,6 +132,8 @@

maxConcurrentRequestsPerProcess="1024" maxNamedPipeConnectionRetry="3" namedPipeConnectionRetryDelay="2000" + maxNamedPipeConnectionPoolSize="512" + maxNamedPipePooledConnectionAge="30000" asyncCompletionThreadCount="0" initialRequestBufferSize="4096" maxRequestBufferSize="65536" diff --git a/src/samples/configuration/web.config b/src/samples/configuration/web.config index 5467553e..6aacd82c 100644 --- a/src/samples/configuration/web.config +++ b/src/samples/configuration/web.config @@ -31,6 +31,12 @@ * namedPipeConnectionRetryDelay - delay in milliseconds between connection retries + * maxNamedPipeConnectionPoolSize - maximum number of named pipe connections that will be kept in a connection pool; + connection pooling helps improve the performance of applications that process a large number of short lived HTTP requests + + * maxNamedPipePooledConnectionAge - age of a pooled connection in milliseconds after which the connection is not reused for + subsequent requests + * asyncCompletionThreadCount - size of the IO thread pool maintained by the IIS module to process asynchronous IO; setting it to 0 (default) results in creating one thread per each processor on the machine @@ -92,6 +98,8 @@ maxConcurrentRequestsPerProcess="1024" maxNamedPipeConnectionRetry="3" namedPipeConnectionRetryDelay="2000" + maxNamedPipeConnectionPoolSize="512" + maxNamedPipePooledConnectionAge="30000" asyncCompletionThreadCount="0" initialRequestBufferSize="4096" maxRequestBufferSize="65536"