Web application scaling and lack thereof

I'm struggling to figure out how to scale any web application that allows the user to log in and depends on which user must log in to perform any action.

For example, I have a web application that allows a user to log in, edit the users address book, send messages to other users, and receive messages from users.

Some recommendations I received are to split my application into services using verbs. Therefore, I will have an address book editing service, a message sending service, a message receiving service, and an authentication service. All of them will be individually scaled horizontally and will not share data. That would be ideal, only they should share the data - the user who is currently logged in. I can not conceptually understand how this will work? Should I just send the user ID between the services and it will be implicit, is this the user who is logged in? What if I want to save a session state with information about what the user is doing now?

+4
source share
1 answer

At some point, all web servers should converge somewhere. This place is usually a database cluster. After the initial authentication, you can create a random string and save it in the current current authentication cookie list in the database. Each time a cookie is sent to one of the servers, the server can check the database cluster to see which user (if any) the cookie is associated with.

I will add that you do not need a database cluster. You could distribute the database on different sites. However, some operations must be synchronous. One of them is the creation of a cookie at the initial login (which will not happen too often). Otherwise, you will have a mixture of servers that make and do not recognize cookies.

+1
source

Source: https://habr.com/ru/post/1402255/


All Articles