PDA

View Full Version : simple query for grid, but 10 webside visiters, db going down



Richie1985
9 Sep 2013, 6:44 AM
hi,

i have a problem with stores and grids.

i reload my store automaticly after 5 seconds, php makes a simple query on the postgres database. when only one is visiting the side there is no problem, but when 10 users view this grid my database is going down :(

all this people look at the same grid and same store and same query and so on, is there a solution? (caching or what ever?)

thx!

existdissolve
9 Sep 2013, 5:01 PM
hi,

i have a problem with stores and grids.

i reload my store automaticly after 5 seconds, php makes a simple query on the postgres database. when only one is visiting the side there is no problem, but when 10 users view this grid my database is going down :(

all this people look at the same grid and same store and same query and so on, is there a solution? (caching or what ever?)

thx!

First question: Why are you reloading the store every 5 seconds?

If your database is going down, then you probably either have some seriously inefficient SQL, some issues with your server setup, or a variety of all of the above.

But part of it could be that you are simply making way too many requests in too short a time for your server to handle.

If your data and query are the same, and (for whatever reason) you *really* do need to reload the store every 5 seconds, then you'll definitely want to put some caching in place. This will help take some of the load off of your database for unnecessary queries. You could put a strategy in place to cache the data until it changes, refresh the cache when the data changes, etc.

Ultimately, though, this is going to be a server-side solution (unless of course you tone down the rate of store reloading).

Richie1985
9 Sep 2013, 10:42 PM
i reload the store because the data is changing every 5 seconds...

but every website visiter see the same data...

for example 1 user is looking at the site, every 5 seconds one query is going to db...

5 users, every 5 seconds 5 querys

10 users, every 5 seconds 10 querys and so on

evant
9 Sep 2013, 10:54 PM
You'd be better off posting in a <your server langugage> forum, this doesn't really have anything to do with Ext.

Richie1985
9 Sep 2013, 11:54 PM
oh okay, i thought it have something with Ext.direct or websocket or something to do, to broadcast the data instead every client makes seperate querys :(

existdissolve
10 Sep 2013, 5:41 AM
i reload the store because the data is changing every 5 seconds...

but every website visiter see the same data...

for example 1 user is looking at the site, every 5 seconds one query is going to db...

5 users, every 5 seconds 5 querys

10 users, every 5 seconds 10 querys and so on

I get what you're saying, but the question is really this: from an interface perspective, is it really necessary that the data is refreshed every 5 seconds? That is, could you get away with refreshing every 20 seconds or 30 seconds, batching together all the new/updated records within that 20-30 seconds? Not only would that drastically reduce the number of round trips needed to retrieve the data, but you'd also be able to implement a (probably) more efficient caching strategy for those longer-lived durations. This alone would drastically reduce the number of database queries (10 users = 60 queries in 30 seconds VS 10 users = 1 query every 30 seconds).

Richie1985
10 Sep 2013, 6:21 AM
okay i understand, i will have a try with reload every 30 seconds what you say (it moves far away from realtime but i will try it)

how can i cache this querys to reach the goal 10 users = 1 query every 30 seconds?

existdissolve
10 Sep 2013, 7:11 AM
okay i understand, i will have a try with reload every 30 seconds what you say (it moves far away from realtime but i will try it)

how can i cache this querys to reach the goal 10 users = 1 query every 30 seconds?

Well, it doesn't have to be 30 seconds...maybe 20 or 10. I'm just offering a suggestion based on your own admission that your server is incapable of handling the extremely small load that you've been experiencing for "real time". Whatever scheme you choose, however, you're going to have to balance what your caching strategy will allow, how much scalable traffic your server can manage at any given time without dying, and what delays you're willing to live with in updating the data. Ext JS will happily play with whatever strategy you adopt...but the solution that is needed is ultimately a server-side one.

Regarding caching the queries, you'll have to post in a forum relevant to the server-side stack that you're using. Without knowing that, it's difficult to offer suggestions for best caching strategies that are relevant for the technologies that you are using.