Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server Or Database

Hi guys I need your opinion.I am in a situation where I need to use ajax so I need to query users info every 30 seconds.....which is more efficient query the server first(say check a text file first) and if there is an update for a user info, do a full blown database query or just directly query the database directly every 30 seconds.Please explain your reasoning so that I can weigh my decision.......thanks in advance.

like image 720
jamal Avatar asked Apr 14 '26 11:04

jamal


2 Answers

I'd cache on the web server, lifetime of 30 seconds and pull all user data to minimize round trips to the DB. I'd also have the client use the web cache, not go to the database.

It's a lot of overhead for minimal gain otherwise

like image 83
gbn Avatar answered Apr 17 '26 00:04

gbn


If you have a small number of users and few web clients, then implement the most simple solution.

Reasoning: There is no need to optimize something like this unless you have severe performance problems. I'd start thinking about this if:

  • There are thousands of users in the DB
  • This info was queries every second by hundreds of web clients

But if you have 10 users, then this probably translates to 10 web browsers asking for this info every 30 seconds. You should worry about the poor CPU on your servers because it's going to be bored to death ;)

like image 23
Aaron Digulla Avatar answered Apr 17 '26 00:04

Aaron Digulla