Skip to content

Commit

Permalink
fix #124: expose configuration for connection pool parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
tjanczuk committed Jan 6, 2012
1 parent 9982779 commit 5781200
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/config/iisnode_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Details at http://learn.iis.net/page.aspx/241/configuration-extensibility/
<attribute name="maxConcurrentRequestsPerProcess" type="uint" allowInfitnite="true" defaultValue="1024"/>
<attribute name="maxNamedPipeConnectionRetry" type="uint" defaultValue="3"/>
<attribute name="namedPipeConnectionRetryDelay" type="uint" defaultValue="2000"/>
<attribute name="maxNamedPipeConnectionPoolSize" type="uint" defaultValue="512"/>
<attribute name="maxNamedPipePooledConnectionAge" type="uint" defaultValue="30000"/>
<attribute name="initialRequestBufferSize" type="uint" defaultValue="4096"/>
<attribute name="maxRequestBufferSize" type="uint" defaultValue="65536"/>
<attribute name="uncFileChangesPollingInterval" type="uint" defaultValue="5000"/>
Expand Down
2 changes: 2 additions & 0 deletions src/config/iisnode_schema_x64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Details at http://learn.iis.net/page.aspx/241/configuration-extensibility/
<attribute name="maxConcurrentRequestsPerProcess" type="uint" allowInfitnite="true" defaultValue="1024"/>
<attribute name="maxNamedPipeConnectionRetry" type="uint" defaultValue="3"/>
<attribute name="namedPipeConnectionRetryDelay" type="uint" defaultValue="2000"/>
<attribute name="maxNamedPipeConnectionPoolSize" type="uint" defaultValue="512"/>
<attribute name="maxNamedPipePooledConnectionAge" type="uint" defaultValue="30000"/>
<attribute name="initialRequestBufferSize" type="uint" defaultValue="4096"/>
<attribute name="maxRequestBufferSize" type="uint" defaultValue="65536"/>
<attribute name="uncFileChangesPollingInterval" type="uint" defaultValue="5000"/>
Expand Down
4 changes: 2 additions & 2 deletions src/iisnode/cconnectionpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
12 changes: 12 additions & 0 deletions src/iisnode/cmoduleconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/iisnode/cmoduleconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
8 changes: 8 additions & 0 deletions src/samples/configuration/readme.htm
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ <h2>
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
Expand Down Expand Up @@ -126,6 +132,8 @@ <h2>
maxConcurrentRequestsPerProcess="1024"
maxNamedPipeConnectionRetry="3"
namedPipeConnectionRetryDelay="2000"
maxNamedPipeConnectionPoolSize="512"
maxNamedPipePooledConnectionAge="30000"
asyncCompletionThreadCount="0"
initialRequestBufferSize="4096"
maxRequestBufferSize="65536"
Expand Down
8 changes: 8 additions & 0 deletions src/samples/configuration/web.config
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -92,6 +98,8 @@
maxConcurrentRequestsPerProcess="1024"
maxNamedPipeConnectionRetry="3"
namedPipeConnectionRetryDelay="2000"
maxNamedPipeConnectionPoolSize="512"
maxNamedPipePooledConnectionAge="30000"
asyncCompletionThreadCount="0"
initialRequestBufferSize="4096"
maxRequestBufferSize="65536"
Expand Down

0 comments on commit 5781200

Please sign in to comment.