Skip to content
This repository has been archived by the owner on Jul 23, 2023. It is now read-only.

Look into using webhooks for listening to new deployments #3

Open
half0wl opened this issue Mar 20, 2023 · 0 comments
Open

Look into using webhooks for listening to new deployments #3

half0wl opened this issue Mar 20, 2023 · 0 comments
Labels
enhancement New feature or request priority/low

Comments

@half0wl
Copy link
Owner

half0wl commented Mar 20, 2023

Context:

/**
* This is the main event loop that refreshes a project's deployments and
* plugins every n seconds (where n=`REFRESH_INTERVAL_SECONDS`) and pushes
* the logs of each deployment/plugin into Vector.
*
* The major limitation of this approach is Railway's rate limit - each
* account is limited to 1k requests per day [0]. At the current default
* refresh interval of 15 mins, that works out to 96 requests every 24
* hours for project data per-project. I'm not sure if the WS subscriptions
* are subject to this rate limit. In theory, rate limits should apply
* per-request instead of per-WS message, which implies each WS connection
* counts toward the rate limit. This effectively means that we're making
* `(1 + (services+plugins)) * (86400 / REFRESH_INTERVAL_SECONDS)` requests
* every 24hours for each project.
*
* An alternative/better way of doing this is through Railway's webhooks.
* We can subscribe to new deployments. However, this approach misses out
* on plugin creation/deletion: when a plugin is created, logs will only
* get pushed after restarting this service. Conversely, when a plugin is
* deleted, we'll have no way of knowing (would subscribing to logs of a
* deleted plugin error out?).
*
* [0] https://docs.railway.app/reference/public-api#rate-limits
*/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request priority/low
Projects
None yet
Development

No branches or pull requests

1 participant