tags:

views:

46

answers:

3

In stackoverflow, and some other websites where people submits questions or posts, there is a delay of 20 seconds before the post displayed, is that means the post is delayed by the SQL server, or the website does not allows instant posting, or it's a CDN cache matter ?

And the important thing , why there is a delay, is it in order to make the server faster, or to give the moderators more time to check the posts?

+3  A: 

It is due to caching.

There is no actual delay doing the insert, it's just that the page you are viewing is actually an old snapshot of the data stored in memory, this dramatically improves performance for database bound task, and it's extremely important for performance.

Paul Creasey
I would go as far as to say that caching is vital to performance.
Jeremy B.
A: 

If you are speaking about an intentional delay, then that's usually indicative of a queuing mechanism which is used to help level off spikes in extreme activity. It would more than likely be a producer-consumer model which would have the posts put in a queue and then the queue is read and the database updated.

It's also possible that you are seeing caching somewhere down the line between the server and your client (it can be through your ISP, through a proxy server, or your own browser cache), and you need to update the page/list.

Speaking specifically of Stack Overflow, I've never seen it take 20 seconds for a question/answer to appear, it's always been instantaneous, and I don't believe such a queue mechanism is implemented, although to be sure, you should probably ask the question on Meta Stack Overflow if you want to know about Stack Overflow specifically.

casperOne
A: 

Of course, on some sites there is a delay because it takes time to do the insert and the server is slammed or the insert is more complicated than you realize including adding records to multiple tables or hitting triggers or the insert just may not be optimized.

HLGEM