Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have an architecture based on multiple stateless webservices loadbalanced with haproxy.

Theses webservices host a cloud storage system that allow users to upload files at a predefined bandwidth depending on the plan the user suscribed. When the user is connected to his space a websocket is opened that handle the upload throught standard TCP websocket (nodejs socket.io).

So my issue here is that i'm unable to find a solution to limit bandwith for each user depending on their plan, without using IP or Port since multiple users could be behind the same IP.

My first idea was to use a combination of iptables and tc on the load balancer to mark packets that contain a string with the algo bm functionnality of iptable and then apply the tc rule according to their plan. The iptables rules matching the string ID would be added by the webservice directly on the loadbalancer during the websocket connection.

The thing is that packets containing data (websocket TCP socket.io connection) doesn't contain any kind of session ID or anything, every packets seems encoded differently.

As you can see this is not really a pure technical issue, I'm just asking for your advice if someone knows an alternative or a better way to handle my problem.

share|improve this question
Just a thought, but have you considered reading in the incoming bytes slowly at the server-side? Read byte, sleep, read another byte, and so forth? Not sure if this might cause problems elsewhere but at least you'd be able to adjust the reading speed based on the user's plan? –  Jukka May 28 '14 at 19:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.