Using NGINX as UDP load balancer at high rate
September 30, 2023 05:12AM
Hi, I’m running nginx on Kubernetes and I want to use it as a UDP load balancer at high rate.
user root;
worker_processes auto;

events {
worker_connections 1024;

stream {
upstream app_node {
server <receiver_ip>:<receiver_port> fail_timeout=60s weight=1;

server {
listen <nginx_port> udp;
proxy_pass app_node;
proxy_protocol on;
proxy_bind $server_addr:$remote_port;

I try to test it by generating high traffic, such as 30,000 packets per second on average for 5 minutes, and each packet size is 1 KB.
I use tcpdump for monitoring packets that nginx receives and sends.

Tcpdump command for receiving packets:
tcpdump -i <receiving_inteface> dst <nginx_pod_ip> and port <nginx_port> -w receceived_30000.pcap

Tcpdump command for sending packets:
tcpdump -i <sending_inteface> src <nginx_pod_ip> and dst <receiver_ip> and port <receiver_port> -w sent_30000.pcap

But the count of packets captured by the two commands is not the same. It seems that nginx drops packets:

Result of first tcpdump command:
9000000 packets captured
9000000 packets received by filter
0 packets dropped by kernel

Result of second tcpdump command:
8997898 packets captured
8997898 packets received by filter
0 packets dropped by kernel

And this difference will increase if we increase the rate of sending packets.
So what is the problem here? Is our configuration wrong, or has something else happened?

Edited 1 time(s). Last edit at 09/30/2023 05:13AM by A_H.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 341
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready