Poor man's stickiness

We have an application that isnt stateless, but i still want to have some spreading of the load.
It has web and app servers behind web and app haproxy clusters.
I was going to load / stick the web frontend based on source ip. However the web servers have to talk to the same app servers for the whole of the user’s session.

Anyone have any thought on how to do this.?

Please elaborate, it is not at all clear what you are trying to achieve.

Are you saying that you have a “web” haproxy cluster, with webservers behind it and then you also have a separate “app” haproxy cluster , with “app” servers behind it, the client accesses both, and there is some correlation between them, for example a client hitting webserver1 must also hit appserver1?

So the application will fail if the client hits webserver1 and appserver2?

The client accesses a website hosted on the webservers. The webserver serves information that it gets by accessing one of the app servers.
One a users has logged into one of the webservers and the webserver has used one of the app servers, the combination of web and app must be used for the users session.

And the protocol between the webserver and the appserver is HTTP I guess?

If I’d be forced to work with this terrible design, I’d use cookie persistence however that requires that the webserver correctly handles cookies towards the appserver. Otherwise you’d have to figure out some other identifying information (like a session ID) in the request of the webserver that makes it possible for haproxy to stick to the same app server.

Yeah http, agreed its a terrible design.
Yeah was thinking some sort of cookie persistence or session id.

Cheers