Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
At this moment it is only possible to have 1 ongoing datbase connection for an entire vweb application. Problems arise when multiple workers need to access that same database connection over multiple threads, see #18006.
This pullrequest adds the option to have a pool of database connections.
Usage
Example with postgres as database.
In this example there are 20 workers and there must be 1 database connection for each worker (thread).
The default nr of workers is the same as for a default app:
DIfferent databases
The above example configured for mysql:
Only the types in the
App
struct need to be changed and the implementation of the pool handler.Compatibility
All older vweb applications with a single db connection will still work so no breaking changes.
Performance
Test script
run.sh
:Output:
Tested on intel i9 12900K with 24 threads (23 workers).
The test was perfomed with this script.$3604+ 3805 = 7409$ request per second.
The load is equally distributed in the app averaging at