Tuesday 19 January 2016

How to optimize Sequelize (pg) + Node;

Hello folks,My question is: if I'm reating something like blog, social network or just some portal how should I handle with sql queryfing?Example #1:User is checking his statisitc and sees: Messages: 234 Games played: 23Now, every time user is reloading /stats page, query is executed. Why? Because after user send a msg or play a game his counter will increase +1. So SELECT count(*) from MESSAGES where id_from = user.id runs on whole big table to fill template engine "messages" variable.Example #2:user is checking out blog. Every refresh (F5) big query is executed to fill template engine with areticle short description, image, date, author etc.Question:How I should prevent such DB overload if 1k users will just check out blog and some users will spam F5? It will just kill my VPS... I'm using Sequelize on PostgreSQL if that means.

Submitted January 19, 2016 at 11:54AM by trickster00

No comments:

Post a Comment