Hi there,
I am trying to set up HAProxy in front of some node js apps but having trouble with performance. In the best case I get just under half the performance of a raw node server.
I have a simple hello world app -
const http = require(‘http’);
const server1 = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader(‘Content-Type’, ‘text/plain’);
res.end(‘Hello World 1’);
});
const server2 = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader(‘Content-Type’, ‘text/plain’);
res.end(‘Hello World 2’);
});
server1.listen(3000, ‘0.0.0.0’, () => {});
server2.listen(3001, ‘0.0.0.0’, () => {});
When I do wrk -c100 -d10 http://localhost:3000 I am getting around 10k req/sec
I set up haproxy and have tried multiple different configs but I can not get even half the speed of raw server. Is that normal?
Here’s my latest config that gets around 4k req/sec -
global
maxconn 50000
log 127.0.0.1:514 local0 info
chroot /var/lib/haproxy
stats timeout 30s
user haproxy
group haproxy
daemon
defaults
maxconn 50000
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
frontend http_front
bind *:5000
stats uri /haproxy?stats
default_backend http_back
backend http_back
balance roundrobin
server server_name1 0.0.0.0:3000 check
server server_name2 0.0.0.0:3001 check
What am I doing wrong or is that normal to have HAProxy cut the req/sec in more than half?
Thank you!