flodgatt/Cargo.toml

50 lines
1.0 KiB
TOML
Raw Permalink Normal View History

2019-02-11 09:45:14 +01:00
[package]
name = "flodgatt"
2019-02-11 18:58:51 +01:00
description = "A blazingly fast drop-in replacement for the Mastodon streaming api server"
version = "0.9.9"
authors = ["Daniel Long Sockwell <daniel@codesections.com", "Julian Laubstein <contact@julianlaubstein.de>"]
2019-02-11 09:45:14 +01:00
edition = "2018"
[dependencies]
log = { version = "0.4.6", features = ["release_max_level_info"] }
futures = "0.1.26"
tokio = "0.1.19"
warp = { git = "https://github.com/seanmonstar/warp.git"}
serde = { version = "1.0.105", features = ["derive"] }
serde_json = "1.0.50"
serde_derive = "1.0.90"
pretty_env_logger = "0.3.0"
postgres = "0.17.0"
dotenv = "0.15.0"
postgres-openssl = { git = "https://github.com/sfackler/rust-postgres.git"}
url = "2.1.0"
strum = "0.16.0"
strum_macros = "0.16.0"
r2d2_postgres = "0.16.0"
r2d2 = "0.8.8"
lru = "0.4.3"
2020-04-03 22:35:32 +02:00
urlencoding = "1.0.0"
hashbrown = "0.7.1"
2019-02-19 20:29:32 +01:00
2019-09-11 23:28:27 +02:00
[dev-dependencies]
criterion = "0.3"
2019-09-11 23:28:27 +02:00
[[bench]]
name = "parse_redis"
harness = false
2019-02-19 20:29:32 +01:00
[features]
default = [ "production" ]
bench = []
2020-04-05 16:54:42 +02:00
stub_status = []
2019-02-19 20:29:32 +01:00
production = []
[profile.release]
2020-04-11 04:56:19 +02:00
lto = "fat"
panic = "abort"
2020-04-11 04:56:19 +02:00
codegen-units = 1
Stream events via a watch channel (#128) This squashed commit makes a fairly significant structural change to significantly reduce Flodgatt's CPU usage. Flodgatt connects to Redis in a single (green) thread, and then creates a new thread to handle each WebSocket/SSE connection. Previously, each thread was responsible for polling the Redis thread to determine whether it had a message relevant to the connected client. I initially selected this structure both because it was simple and because it minimized memory overhead – no messages are sent to a particular thread unless they are relevant to the client connected to the thread. However, I recently ran some load tests that show this approach to have unacceptable CPU costs when 300+ clients are simultaneously connected. Accordingly, Flodgatt now uses a different structure: the main Redis thread now announces each incoming message via a watch channel connected to every client thread, and each client thread filters out irrelevant messages. In theory, this could lead to slightly higher memory use, but tests I have run so far have not found a measurable increase. On the other hand, Flodgatt's CPU use is now an order of magnitude lower in tests I've run. This approach does run a (very slight) risk of dropping messages under extremely heavy load: because a watch channel only stores the most recent message transmitted, if Flodgatt adds a second message before the thread can read the first message, the first message will be overwritten and never transmitted. This seems unlikely to happen in practice, and we can avoid the issue entirely by changing to a broadcast channel when we upgrade to the most recent Tokio version (see #75).
2020-04-09 19:32:36 +02:00