Using Views for high traffic web sites

Events happening in the community are now at Drupal community events on www.drupal.org.
gansbrest-gdo's picture

I would like to know if you guys using Views for high traffic web sites or not?

There are a lot of mess in our current websites.. Some of the pages and blocks were built using views and some of them using about 6000 queries to display nodes listing on the page! And some using custom modules and custom queries. I personally prefer to write custom code because it easier to maintain and it's easier to find where is that query if u need to modify it.

Should we use Views for further development or should we write custom queries instead - it's a big debates among our developers.. Half of the team prefer to use Views and the other half - not to! We're currently running Drupal 5 and Views 1.0 - and I've heard that View 2.0 will do the magic...

I would like to know u thoughts about Views usage!

Comments

Views mean faster

Etanol's picture

Views mean faster developement and more rapid adaptation should you need to change the website. On the other hand if you use custom code you get more control, which might give you edge performance-wise.
As for numerous queries while building blocks use block cache - unless the block has to be rebuild number of queries will drop to 1/block.

Depends ...

kbahey's picture

Good advice from Etanol, as always ...

It really depends on many things.

How high is the traffic on the site? If you are, say, in the tens of thousands of page views a day, then probably views would be usable if you do not clutter the page with lots of blocks that are views (generally a good practice whether you use views or not).

Is your audience mainly not logged in? If you site's visitors are mostly anonymous, then using caching with memcache and 15 minutes minimum lifetime should reduce the load on the site significantly.

Can you prototype then tune? If you can settle on a finite number of views, then convert those to custom code with less queries before going live, you get to use views as a RAD tool, yet not go live with only views querying the database. If the site editors will continue to regularly create views after going live, then there will be trouble.

Drupal performance tuning, development, customization and consulting: 2bits.com, Inc..
Personal blog: Baheyeldin.com.

Drupal performance tuning, development, customization and consulting: 2bits.com, Inc..
Personal blog: Baheyeldin.com.

Check Queries With Devel

Jamie Holly's picture

Great advice above. Something else to make sure everything runs smooth is to install the Devel module and enable the query log and output in the settings page. There's a good chance a view won't have a proper index available, so you will have to create it. Having the proper index can be the difference between night and day, especially with tables that have a large number of rows. I did some work for a friend's s site a few weeks ago who was using Views rather heavily. They could handle up to about 7,000 page views in an hour. At 10,000 and their site went down. I found a couple of queries and gave them proper indexes. Since then they had a couple of hours with over 15,000 page views and the site never slowed down. The big thing is to do explains on the query and to get indexes that prevent the query from doing filesorts. Those are like the overturned semi on the highway, blocking up traffic for miles.


HollyIT - Grab the Netbeans Drupal Development Tool at GitHub.

Contribute patches please

kbahey's picture

If these queries are in contributed modules that are released on drupal.org, then please create patches for said indexes and submit them in the issue queue.

This way, everyone can benefit from this tuning.

Drupal performance tuning, development, customization and consulting: 2bits.com, Inc..
Personal blog: Baheyeldin.com.

Drupal performance tuning, development, customization and consulting: 2bits.com, Inc..
Personal blog: Baheyeldin.com.

I'm an indexing fool and if

Jamie Holly's picture

I'm an indexing fool and if I see something from a module I have used (or core) that benefits from a better index, I put a patch in. There really isn't applicable to Views though since there is so many possibilities with search criteria, relationships, sort order. Whenever I talk to someone using Views, I always tell them to take a couple of minutes and make sure the queries it generates are using proper indexes.


HollyIT - Grab the Netbeans Drupal Development Tool at GitHub.

I would generally prefer to

KingMoore's picture

I would generally prefer to write my own queries instead of using views. It's not hard to do, and then I don't have to worry about queries being generated unefficiently inside code I have no control over -- unless I am just trying to get a site online quick and don't really ever expect it to get much traffic. But then who really cares about performance in that situation.

Views 2 and performance tuning

juan_g's picture

Among the new Views 2 features for site admins, we can read the following:

"Upon previewing, performance timers show how long your View took to build, query, and render. Great for quick performance tuning."

Also, as it's well-known, caching can really help to improve speed and performance. For instance with performance and scalability modules such as Boost, Memcache, Cache Router, Advanced Cache, etc.

High performance

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: