Skip to content

Commit

Permalink
Added requestQueueSize config option, updated docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewlalis committed Dec 8, 2023
1 parent 9ed5585 commit 270f39a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
8 changes: 8 additions & 0 deletions docs/src/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ An associative array of headers that will be added to every response the server

These options can be used to configure the general server behavior.

### `requestQueueSize`
| Type | Default Value |
|--- |--- |
| `size_t` | `128` |
The size of the queue used to distribute incoming requests to worker threads. Increasing this number can improve performance marginally, but shouldn't really matter unless you're near the limits of what's possible with Handy-Httpd.

Note that internally, the queue is implemented with a fixed-size array.

### `workerPoolSize`
| Type | Default Value |
|--- |--- |
Expand Down
6 changes: 3 additions & 3 deletions docs/src/guide/handling-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ void handle(ref HttpRequestContext ctx) {

If a request is handled by a [PathHandler](ddoc-handy_httpd.handlers.path_handler.PathHandler), then its `pathParams` associative array will be populated with any path parameters that were parsed from the URL.

The easiest way to understand this behavior is through an example. Suppose we define our top-level PathDelegatingHandler with the following mapping, so that a `userSettingsHandler` will handle requests to that endpoint:
The easiest way to understand this behavior is through an example. Suppose we define our top-level PathHandler with the following mapping, so that a `userSettingsHandler` will handle requests to that endpoint:

```d
auto handler = new PathDelegatingHandler();
auto handler = new PathHandler();
handler.addMapping("/users/:userId:ulong/settings/:setting", userSettingsHandler);
```

Expand All @@ -72,7 +72,7 @@ void handle(ref HttpRequestContext ctx) {
}
```

For more information about the PathDelegatingHandler, please see the [dedicated page on this topic](./handlers/path-handler.md).
For more information about the PathHandler, please see the [dedicated page on this topic](./handlers/path-handler.md).

#### Body Content

Expand Down
9 changes: 0 additions & 9 deletions docs/src/guide/using-vue.md

This file was deleted.

6 changes: 6 additions & 0 deletions source/handy_httpd/components/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ struct ServerConfig {
*/
int connectionQueueSize;

/**
* The size of the internal queue used for distributing requests to workers.
*/
size_t requestQueueSize;

/**
* The number of worker threads for processing requests.
*/
Expand Down Expand Up @@ -73,6 +78,7 @@ struct ServerConfig {
cfg.hostname = "127.0.0.1";
cfg.port = 8080;
cfg.receiveBufferSize = 8192;
cfg.requestQueueSize = 128;
cfg.connectionQueueSize = 100;
cfg.reuseAddress = true;
cfg.workerPoolSize = 25;
Expand Down
2 changes: 1 addition & 1 deletion source/handy_httpd/server.d
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class HttpServer {
this.config = config;
this.address = parseAddress(config.hostname, config.port);
this.handler = handler;
this.requestQueue = new ConcurrentBlockingRequestQueue();
this.requestQueue = new ConcurrentBlockingRequestQueue(config.requestQueueSize);
this.exceptionHandler = new BasicServerExceptionHandler();
this.workerPool = new WorkerPool(this);
if (config.enableWebSockets) {
Expand Down

0 comments on commit 270f39a

Please sign in to comment.