- Newest
- Most votes
- Most comments
To configure a Network Load Balancer (NLB) to support Gearman traffic over TCP port 4730 and enable auto scaling, you can follow these steps:
-
Create a target group:
- Choose the target type as "IP" or "Instance" depending on your setup.
- Specify the protocol as TCP and the port as 4730.
- Configure health checks appropriate for your Gearman server.
-
Create the Network Load Balancer:
- Select the VPC where your Gearman servers are located.
- Choose the Availability Zones you want to enable.
- Set the IP address type (IPv4 or dualstack).
-
Configure a listener for the NLB:
- Set the listener protocol to TCP and the port to 4730.
- Associate the listener with the target group you created.
-
Register targets:
- Add your Gearman server instances or IP addresses to the target group.
-
Create an Auto Scaling group:
- Select the appropriate launch template or configuration for your Gearman servers.
- Choose the VPC and subnets where the instances should be launched.
- Set the desired capacity, minimum, and maximum number of instances.
- Configure scaling policies based on memory metrics (you may need to set up custom CloudWatch metrics for this).
-
Associate the Auto Scaling group with the target group:
- This ensures that new instances are automatically registered with the NLB.
-
Create a DNS record:
- In your DNS service (e.g., Route 53), create an A record for "gearman.example.com" pointing to the NLB's DNS name.
-
Update your application configuration:
- Modify your application to use "gearman.example.com" instead of private IPs when connecting to the Gearman server.
This setup will allow your application to communicate with the Gearman servers through the NLB using the DNS name, supporting auto scaling and eliminating the need for static IPs. The NLB will distribute incoming Gearman traffic across the healthy instances in the target group, improving reliability and performance.
Remember to configure appropriate security groups to allow traffic on port 4730 between your application instances and the NLB, and from the NLB to your Gearman server instances.
Sources
Network Load Balancers - Elastic Load Balancing
How to prepare architecture for 1 public elastic IP and multiple ec2 instances with routing based on port | AWS re:Post
Relevant content
- asked 4 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 5 months ago

A side note: Its not recommended to scale based on Memory. Most applications will allocate it, but never or slowly remove that allocation. So you'll get to a scale-out point, but the metric won't go down, so you'll keep scaling out extra instances
It might be better to see if there's a metric which goes up similarly and can be used to scale on instead, like RequestCountPerTarget (you'd need to publish this as a custom metric); or any other metric correlated with load