Project

General

Profile

Wt SimpleChat example, is it tied to just one server installation?

Added by Plug Gulp almost 5 years ago

Hi,

I am going through the SimpleChat example from the Wt example directory. From the code it looks like the client and the server handling has to be on the same server. Is my understanding correct? Say, for example I have two boxes running the Wt SimpleChat server, both these servers are behind a load balancer. Now two users sign into the chat application. The load balancer redirects one user to first server and the other user to another server. Will these two users be able to communicate? My understanding is no. Am I correct? In short, is the architecture of the SimpleChat example horizontally scalable?

Thanks and kind regards,

~Plug


Replies (2)

RE: Wt SimpleChat example, is it tied to just one server installation? - Added by lm at almost 5 years ago

Plug Gulp wrote:

From the code it looks like the client and the server handling has to be on the same server.

The client and server should be on different machines.

Say, for example I have two boxes running the Wt SimpleChat server, both these servers are behind a load balancer. Now two users sign into the chat application. The load balancer redirects one user to first server and the other user to another server. Will these two users be able to communicate? My understanding is no. Am I correct?

According to my understanding, your reasoning is correct. It is possible to make this example so that it can run behind a load balancer, but of course the nature of a chat server is such that all traffic needs to be handled by all server nodes.

You've probably already noticed, but the reason only one server node will work is because the application uses server memory to store all state. That also means that restarts do not persist any state.

The solution is not to rely on server memory, but instead some central store (a database is the obvious choice here) for state.

Let us know if you have further questions or would like more details.

RE: Wt SimpleChat example, is it tied to just one server installation? - Added by Roel Standaert almost 5 years ago

The simplechat example is of course just a simple example where only communication inside of the same process is possible. It's more demonstrating how different WApplications deployed on the same WServer can communicate.

If you want to put servers behind a load balancer, you'll need to do your own communication between those servers. That is something that Wt is agnostic about. It could be some database (relational or otherwise), it could be a message passing system,... Wt is only concerned with the web part.

    (1-2/2)