Scaling
This document helps you think about scaling Hyvor Relay. It might oversimplify certain aspects,
but it should give you a good starting point.
Postgres Max Connections
Hyvor Relay heavily relies on Postgres connections. Email, webhook, and API workers all create
Postgres connections. You need to ensure that your Postgres instance can handle the total number
of connections created by all workers:
- Email workers: 1 connection per worker
- Webhook workers: 1 connection per worker
- API workers: 1 connection per worker when handling a request
Increasing Max Connections
The default max connection limit is 100. As a first step, you can increase it based on available RAM on your
Postgres server. A common recommendation is to allocate 1 connection per 10MB of RAM. For example, if your Postgres server has 32GB RAM, you can set max connections to 320. Note that this
is a general recommendation, and you might also need to consider other system resources.
Scaling Examples
Here are some examples of scaling Hyvor Relay for different email sending volumes. We assume the
following in all examples:
- A SMTP delivery takes around 200ms on average, but we will assume 1s to be conservative.
- We will only consider email workers for simplicity, but in a real-world scenario, you should
also consider API (required to receive email sending requests) and webhook workers
(optionally, if used).
- We will assume that email requests are evenly distributed throughout the day, for example
when sending transactional emails. If you are sending bulk emails, you need to consider peak
loads.
- We will assume that each email is a simple email without large attachments.
1 Million Emails Per Day
Sending 1 million emails per day is easily achievable with Hyvor Relay with just one app server
and Postgres default settings. Here's a breakdown of the requirements:
- 1 million emails per day = ~11.57 emails per second
- You can achieve this with 12 email workers on a single app server (4GB, 2 vCPU) and default
Postgres settings (max connections = 100)
10 Million Emails Per Day
Sending 10 million emails per day requires more resources. Here's a breakdown of the
requirements:
- 10 million emails per day = ~115.74 emails per second
- You need about 120 email workers to handle this volume.
- Assuming each send log (content, headers, etc.) takes about 10KB of storage, you will need
about 1.2TB of storage per day for send logs alone.