Jump to content

The 10 nations per page thing during peak hours


Recommended Posts

It's to reduce simultaneous database queries. It takes just as many queries to get 40 nations no matter how you split it up, but doing it 10 at a time means you spread it out more.

That's the theory. I'm going to test it for a couple of days to see if it helps any.

Link to comment
Share on other sites

It depends on what the user wants, I think. If he just wants to see 10 nations, then yes, it will be faster.

If the user wants to check a lot of nations at once, then it will be slower though to have everything load by the 10.


Assume accessing and releasing the database connection are atomic operations, and assume that your query is automagically getting everything sorted in the right order. (You cannot control it anyways, as that part is done in whatever you use to access the database.)

Getting 40 nations at once:

1 Access database connection

40 nation queries

1 release database connection.

Total: 42 operations

Getting 40 nations by the 10:

1 Access database connection

10 database queries

1 release database connection

rinse and repeat 3 more times

total: 48 operations.

However, there is a catch. Assume the process that executes all those queries never gets interrupted for such 'trivial' things as OS stuff.

With 40 countries at once, the user hogs the processor for 42 operations, then releases it for another user to use it for his queries.

However, if you do 10 countries at once, then the user hogs the processor for 12 operations, then releases it for another user.

To make this even more fun, all the operations I described aren't atomic at all. Getting the database access actually takes a while, the queries run relatively fast after that. Taking a value of 2 for the operation of opening the database, and 1 for closing/query, then you are at 43 vs 52. 3: 44 vs 56. etc.

My educated guess: limiting it to 10 users in peak-time will increase the number of users that can connect to the site per second, but that is offset by the higher number of times some users will want to visit the site, resulting in a longer peak-time.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...