The Blog That Is No More
This Blog has moved to http://www.success.grownupgeek.com
Sunday, March 04, 2007
  Making Drupal Faster

How to make Drupal faster seems to be my mantra lately. In my previous post, "Drupal is still faster" I bragged about how disabling User-Pictures (avatars) reduced CPU overhead dramatically, and greatly improved the response time of the site. The only problem is that as GrownUpGeek.com becomes more of a social-site, those user avatars are important!

I posted my user-pictures CPU usage problem at the Drupal Support Forum, and as expected have gotten zero responses. That was expected, seeing as how Drupal is free, and nobody is obligated to help or answer - leaving me to figure out the problem all on my own. What I have found after hours of Googling is that the GD Library is responsible for the excessive CPU usage while rendering the avatars. This makes sense but it does not explain why only some avatars cause problems.

Due to public demand I have re-activated the user-pictures but have chosen to display only certain user's avatars (like mine, moderators, etc) in the forums. I accomplished this by creating a new, hidden checkbox field in all members user profiles with the Profile module that I could then use to choose which members I want to have avatars displayed. I then added this PHP code to my node-forum.tpl file (I'm using FlatForum):
profile_load_profile($curr_user);if ($picture && $curr_user->profile_useImage) {print $picture;}
This queries the "profile_useImage" field that I created to determine if the avatar should be displayed or not. I only did this for the forums because that is where most traffic is, but it could also be used in nodes/blog template files as well. I found how to do this in the Drupal Forums, so even though I dont always get answers, it is still a great resource.

In addition to only displaying selected member avatars I have also further reduced the size limits on avatars to only 50x50px and 10kb in size. I will try these methods for a few days to see how the CPU usage looks. If CPU usage is still too high, and if I still cant get any answers to the GD Library CPU-hogging problem I will probably just remove all avatars from the forum areas altogether. I can do this by removing the "Profile_load_profile" code (above) from the node-forum.tpl.php file. This will prevent user-pictures from displaying in the forums, while leaving them in other areas of the site.

Labels: ,

 
Comments:
I dunno much about drupal but from a programming perspective running a cron to generate the thumbnails would seem to be the solution
 
Post a Comment

Subscribe to Post Comments [Atom]



Links to this post:

Create a Link



<< Home

__________________________