2 ms·
Yes, it would, but you might be better served to rethink your app design to return multiple result sets, and/or do most of the relevant joining/filtering on the
by sokoloff 16y ago
Yes, it would, but you might be better served to rethink your app design to return multiple result sets, and/or do most of the relevant joining/filtering on the database, even if your DB is <1ms away from your web farm.
We run a good sized e-commerce site (Alexa top 1000; barely) and our ratio of DB queries per dynamic page is right around 2.5:1. You might not be able to get your query-per-page ratio into that range, but hundreds is certainly too many, IMO. Even "dozens" would be cause for concern, IMO. Moving your webfarm to a different datacenter than your DB is going to shine a spotlight on that problem, but even without that spotlight, you still have a problem.
PS: Even with pushing that amount of work to the DB, we have almost the inverted ratio of web servers to DB servers as you report.
- schammy 16y agoWell, most of those queries are just to look up the "name" for a given ID. And of course we use memcached to cache almost everything. But it still requires a bunch of round trip requests to either the database or memcached. Before anyone asks "why don't you just use a join?" it's because we have tons of different types of data stored in a couple of summary tables. It's 100x faster to just grab all the IDs and values, and then grab the names one at a time (most of which will always be in memcached) than to do it as a join. Don't believe me? We used to do it that way and the performance sucked.