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.