mastodon / flodgatt

A blazingly fast drop-in replacement for the Mastodon streaming API server
GNU Affero General Public License v3.0
86 stars 8 forks source link

Connection pool #12

Closed codesections closed 5 years ago

codesections commented 5 years ago

This PR significantly restructures the under-the-hood organization of the server to add a connection pool where any number of clients can share connections to the same Redis PubSub subscription. (With the past structure, each client opened its own subscription, even when subscribing to the same channel, such as timeline:public). This change significantly increases server's ability to handle large numbers of concurrent requests.

Additionally, this PR adds code to monitor the number of clients connected to a channel and close the channel when no clients are connected, which prevents the number of open connections from growing over time.

This PR also imposes a hard cap on the number of open connections (currently hard-coded; eventually, this will be user-configurable). When the cap is reached, the server will cause new clients to wait for an open connection, avoiding Redis/open-file errors created on some systems when too many pubsub connections are open simultaneously.

Finally, this PR adds a bit of documentation to the README to clarify the code flow. This documentation should probably be moved before 1.0.0, but provides the basics of the structure for future reference.

Gargron commented 5 years ago

At what point do you think it'll become possible to test the server in production? Should we create some kind of milestone/project within the repository to keep track of progress towards that?

codesections commented 5 years ago

Should we create some kind of milestone/project within the repository to keep track of progress towards that?

Good idea; I've done so in #13

At what point do you think it'll become possible to test the server in production?

Sometime around May 10 or before (see the linked roadmap for details).