PHP which is best for storing data in session and database?

I am creating a website that shows recommended pages to users.

Users simply click the next button to browse the various recommended web pages.

I want to check all the actions that users can take.

So, I'll check the pageviews that users actually see.

1. there is a 'user_pageview' column for each users.
2. the numbers will increase every time if users click next button.

      

I can send a request to update the data every time.

However, I find this step will annoy my server.

So, I'm going to temporarily save the data in the session and save it later.

What do you think?

+3


source to share


3 answers


Yes, it will "annoy your server".
Likewise, you "annoy" your car by driving it.

The purpose of the database server is to manage the data store, retrieve, filter, etc.
There is nothing essential about storing data in a database.



There may be a problem, yes, with rebuilding the index (if any).
However, there would be a problem with the user tracking session.

So, I won't bother with the session until I have a problem with the database (which most likely never happens).

+3


source


I don't see what's wrong with increasing the user_pageview page on every pageview, you can do

update table views set user_pageview = user_pageview + 1 where page_id = 4

      



Your PHP script would be connected to your DB anyway, and this request alone shouldn't kill your server.

+1


source


Saving this session is also "annoying" to your server, as you will need to make a request to save it to the session.

If you mean db server my question is this is the problem. Have you noticed that the db server is becoming a bottleneck? I don't think so, because the db server should handle this easily.

However, you do have db performance issues AND ONLY THEN should you find a way to get the db server out of caching. For example, you can store it in the session (make sure you update the db before the session is destroyed) or using the client side cache (local storage).

Again you only have to look at this IF the db server becomes the bottleneck. And if so, I will first try to check that WTH is going wrong with my db (why is this bottleneck).

0


source







All Articles