3 ms·
It is slow for me as well. It seems that page needs some optimizations in order to be served and rendered faster when the server is under heavy loads. 1. I che
by andreas_bak 16y ago
It is slow for me as well. It seems that page needs some optimizations in order to be served and rendered faster when the server is under heavy loads.
1. I checked responses using FireBug plugin and it seems that pages are served uncompressed. For example the front page of the site (only html) is 31K uncompressed, with gzip compression it becomes 6.3K (80% smaller size means 80% less bandwidth to use). Most of web servers support compression.
2. All pages seem to be generated on every request, e.g. no HTTP cache is used on server side. Because I did not found any response headers set by caches. If for example, each page was cached just for 1 to 5 seconds it will reduce the stress on database and cpu significantly. On the other hand it will not impact user experience, because cached version is short lived and fresh results will appear on time. For example the front page is the most requested page of the site, assume that it is requested 100 times per second which means 100 queries to the database etc. If this page is cached for 1 second queries and html composition is reduced to 1 time per second. Personally, HTTP caching on server side is my favorite choice because you don't need to modify the program to use it. (super-fast Varnish cache is the most flexible solution I found).
- smackfu 16y agoWouldn't server side caching run into issues since the page is different for each user? For instance, all the vote up/down buttons seem to have your username hardcoded into them as the href.
- preek 16y agoYes, it would. I don't know how many people are not logged in, though. Those pages could be cached for a minute or so.
- andreas_bak 16y agoYes you are right. I did not notice it. HTTP cache is effective on resources that are same for all users. One possible solution is to decouple the personalized data and load it separately using AJAX. Votes are already implemented in a similar way. Generally, I am proponent of HTTP caching. It requires some modifications of web sites in order to be effective but still the whole system remains less complicated, compared to implementations of cache on back-end (like `memcached'). For example reddit, which is similar to HN, is in constant struggle with their cache subsystems (http://blog.reddit.com/2010/05/reddits-may-2010-state-of-servers.html http://blog.reddit.com/2010/05/reddits-may-2010-state-of-ser...). I believe it can be avoided by keeping cache and web site code apart.
- smackfu 16y agoI know rails has the concept of caching HTML snippets, so you still have the page construction cost, but you avoid the database calls.