Use Session or use database?

Asked

Viewed 152 times

0

Summary: what alternative would "save" the server? Save a huge array in a Session (name, email, Cpf, city etc) or always make a query in the database (mysql) when you need information (considering that every second hundreds of queries are being performed)?

I never had to worry about this kind of thing, but now I have a client who has a site with more than a thousand simultaneous accesses and the server is terrible (I already suggested changes, new servers/ services and everything was barred), it is always falling. So I’m concerned about a system that I’m developing. Basically, this system deals with user registration and consultation of users in the database. Since the server is already bad, I don’t know which alternative (Session or db queries) would be "less worse".

On the duplicate: no answer to the question was conclusive and the author also said nothing.

  • Possible duplicate of Session vs Database Query

  • In fact, I believe the question is based on opinions. It seems to take each answer according to a different point of view.

  • The same is to have a server that includes the application. Doing half-assed patches is a bad way to try to save money (I know, sometimes it’s the fault of the "manager").

3 answers

0

It depends on how much you access and need this data, and "where" would be interesting to store it.

Because there are many accesses, the more client-side you play, the more free your server, and vice versa.

With the server in mind, of course, if you already have a Session open for each user, then it’s better to have it in $_SESSION, since the database request requires more processing than a simple Session query.

You can also think of cookies, and the client pass you some necessary parameter in a request.

There are several factors that come into consideration (security, server, client, structure, etc), but it all depends on your need.

0

I recommend to use SESSION for your user’s personal data for use of the application and only this, the rest would be done by queries to the same BD.

How much the number of users and simultaneous access is necessary a study for better performance of the application, and if a user is not satisfied with the presentation of the content generating errors or long to see its content this will generate dissatisfaction of the same.

A technical study shall be submitted for improvement at all times.

-1

Look, I’ll be brief. I believe it should be stored on a server anyway. If you store it in the bank, you may run the risk, depending on some variables, of the Dead lock occurring in the bank.

Regarding server usage, if it is not supporting, unfortunately the solution is to scale.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.