feat: database pool_size
This commit is contained in:
@@ -2,9 +2,9 @@
|
|||||||
[](https://hub.docker.com/r/sjdonado/bit)
|
[](https://hub.docker.com/r/sjdonado/bit)
|
||||||
[](https://hub.docker.com/r/sjdonado/bit)
|
[](https://hub.docker.com/r/sjdonado/bit)
|
||||||
|
|
||||||
Lightweight URL shortener service with minimal resource requirements. Average memory consumption is under **20MiB RAM** and single CPU core consumption under 30%.
|
Lightweight URL shortener service with minimal resource requirements. Average memory consumption is under **20MiB** and single CPU core consumption under 30%.
|
||||||
|
|
||||||
bit is highly performant, achieving maximum **15.3K RPS** with a minimum latency of 48.89ms with 100K requests using 100 connections. For detailed benchmark results, see [benchmark](docs/SETUP.md#benchmark).
|
bit is highly performant, achieving maximum **15.3K RPS** with a minimum latency of 48.89ms for 100K requests using 100 connections. For detailed benchmark results, see [benchmark](docs/SETUP.md#benchmark).
|
||||||
|
|
||||||
Images available on [Docker Hub](https://hub.docker.com/r/sjdonado/bit/tags).
|
Images available on [Docker Hub](https://hub.docker.com/r/sjdonado/bit/tags).
|
||||||
|
|
||||||
|
|||||||
+12
-2
@@ -1,6 +1,6 @@
|
|||||||
require "sqlite3"
|
require "sqlite3"
|
||||||
require "crecto"
|
require "crecto"
|
||||||
require"micrate"
|
require "micrate"
|
||||||
|
|
||||||
module App::Lib
|
module App::Lib
|
||||||
class Database
|
class Database
|
||||||
@@ -9,7 +9,17 @@ module App::Lib
|
|||||||
Query = Crecto::Repo::Query
|
Query = Crecto::Repo::Query
|
||||||
|
|
||||||
config do |conf|
|
config do |conf|
|
||||||
conf.uri = ENV["DATABASE_URL"]
|
base_url = ENV["DATABASE_URL"]
|
||||||
|
separator = base_url.includes?("?") ? "&" : "?"
|
||||||
|
|
||||||
|
db_url = base_url + separator +
|
||||||
|
"pool_size=20" +
|
||||||
|
"&max_idle_pool_size=10" + # Keep connections ready
|
||||||
|
"&journal_mode=WAL" + # Write-Ahead Logging for concurrent reads
|
||||||
|
"&synchronous=NORMAL" + # Better performance with reasonable safety
|
||||||
|
"&foreign_keys=true"
|
||||||
|
|
||||||
|
conf.uri = db_url
|
||||||
end
|
end
|
||||||
|
|
||||||
if ENV["ENV"] == "development"
|
if ENV["ENV"] == "development"
|
||||||
|
|||||||
+2
-2
@@ -27,7 +27,7 @@ docker run \
|
|||||||
--name bit \
|
--name bit \
|
||||||
-p 4000:4000 \
|
-p 4000:4000 \
|
||||||
-e ENV="production" \
|
-e ENV="production" \
|
||||||
-e DATABASE_URL="sqlite3://./sqlite/data.db?journal_mode=wal&synchronous=normal&foreign_keys=true" \
|
-e DATABASE_URL="sqlite3://./sqlite/data.db" \
|
||||||
-e APP_URL="http://localhost:4000" \
|
-e APP_URL="http://localhost:4000" \
|
||||||
-e ADMIN_NAME="Admin" \
|
-e ADMIN_NAME="Admin" \
|
||||||
-e ADMIN_API_KEY=$(openssl rand -base64 32) \
|
-e ADMIN_API_KEY=$(openssl rand -base64 32) \
|
||||||
@@ -52,7 +52,7 @@ dokku letsencrypt:enable bit
|
|||||||
dokku storage:ensure-directory bit-sqlite
|
dokku storage:ensure-directory bit-sqlite
|
||||||
dokku storage:mount bit /var/lib/dokku/data/storage/bit-sqlite:/usr/src/app/sqlite/
|
dokku storage:mount bit /var/lib/dokku/data/storage/bit-sqlite:/usr/src/app/sqlite/
|
||||||
|
|
||||||
dokku config:set bit DATABASE_URL="sqlite3://./sqlite/data.db?journal_mode=wal&synchronous=normal&foreign_keys=true" APP_URL=https://bit.donado.co ADMIN_NAME=Admin ADMIN_API_KEY=$(openssl rand -base64 32)
|
dokku config:set bit DATABASE_URL="sqlite3://./sqlite/data.db" APP_URL=https://bit.donado.co ADMIN_NAME=Admin ADMIN_API_KEY=$(openssl rand -base64 32)
|
||||||
|
|
||||||
dokku ports:add bit http:80:4000
|
dokku ports:add bit http:80:4000
|
||||||
dokku ports:add bit https:443:4000
|
dokku ports:add bit https:443:4000
|
||||||
|
|||||||
Reference in New Issue
Block a user