Pressflow, Locked Tables & Hang Time

Pressflow, Locked Tables & Hang Time

I just installed Pressflow and simultaneously updated Drupal late last week. Pressflow is a modified version of Drupal that allows it to scale more easily. For sites with huge traffic and databases, it's essential. It supports database replication, Squid and Varnish reverse-proxy caching, and is optimized for MySQL and PHP 5.

I plan to use some of those features in the future, but my main reason for installing it is to get rid of the table locks from Drupal. During heavy load, the database locks don't crash the site, but it does cause the site to hang for a minute or two. This happens several times a day, if not more. One of the co-founders and developers of Pressflow told me this distribution of Drupal would get rid of the table locks, so I went ahead and installed it. Because it's a just modified version of Drupal, the installation/upgrade process is the same. I could have just converted the problematic MyISAM tables into InnoDB, but Pressflow offers more upside. Since installing it, the site hasn't had any of those one-to-two minute hangs. Although, I do occasionally see locks on the cache tables, but it's not enough to cause the site grind to a halt.

One command that I issue all the time in MySQL is "show processlist." I saw a couple queries that were writing to disk (instead of memory), which slowed down the site and caused it to hang. When it's writing to disk, it means that there's not enough RAM to store the results, so it goes to the hard drive. You can solve this either by brute force or by simplifying the query. I chose brute force because I recently added more RAM to my VPS at Linode. I noticed that my system was only configured to max out at 60%, so I increased the "key_buffer_size" from 16MB to 200MB in the MySQL config file. Now, my RAM usage maxes out at around 80%, and I'm seeing less writing to disk and less hang time.

I still have to optimize some more queries in the slow query log to make the site load faster for logged-on users. Anonymous users get cached pages, which loads up pretty fast. Right now, I don't have any registered users, but I plan to open up a community section for the site soon, and that's why I'm doing all these performance optimization stuff now. I've been holding off on community related features like blogs, forums, and social networking because they're resource intensive. I want to make sure my server and code are in tip-top condition before setting them up.

Sections:  note from the editor   
Topics:  cms   coding   drupal   linode   locked tables   mysql   php   pressflow   site updates   vps   wopular   
  • "Storm The Gates" Mobile Game
    My friends just launched a mobile game called "Storm the Gates"! It's available on both Android and iOS. I'm not much of a gamer, so I didn't know what to do when I started it. But my 9-year-old son turned it on and knew exactly what to do. More
  • "Ip Man 3" Has New Release Date in China and Posters to Prove It
    Over at, I’ve written two articles regarding “Ip Man 3,” the film that’s holding its own in Asian territories against “Star Wars: The Force Awakens.” If you’re not familiar with Asian cinema,”Ip Man” one of the most popular franchises in that area of the world. More
  • Live-Blogged The Golden Globes at MWB
    Yesterday, I live-blogged The Golden Globes -- for various reasons. First, it gets traffic. Second, I might as well do something useful while watching TV. Lastly, I was looking forward to seeing Ricky Gervais host the event again. Nothing against Tina Fey and Amy Poehler, but he’s my favorite. A google search revealed that the last time I did this for this award show was More
  • Kings vs. Mavs: Ominous Stats, News for Sacramento Before Game
    The preview on and the injury report from don’t look good for the Sacramento Kings going into tonight’s game against the playoff-bound Dallas Mavericks. More
  • What?! Kings Beat Thunder, 116-104
    (Image from the Sacramento Bee. Click here to view more images from the game.) What a win. It was a wild one, especially in the first half. We [Sacramento Kings] were down by 17 in the first quarter. In frustration, I was about to turn off the TV, but the teaml called a timeout. More
  • Finally, Got Rid of That Pesky Count Query
    While updating Wopular, I noticed that from time to time, the site would locked up for a couple minutes. Most of the time, I would just wait it out. I finally looked into the slow query log for mysql and found the troublesome query. More
  • Improving MySQL Performance with Query Cache
    In my continued efforts to make the site run faster, I’ve set my sights on query caching on MySQL. I think query caching is turned on by default when you install MySQL. At least for me, I didn’t have to do anything. More
  • Finally Upgraded Sites to Use New Hardware from Linode Cloud: SSDs, Double RAM, Faster CPUs
    Around April, my VPS provider Linode announced that they’ve just finished a major $45M upgrade to their hardware and network, which means free upgrades for their existing users. The new hardware uses SSD RAID drives and faster CPUs. I hadn’t bothered because Wopular and Movies With Butter have been relatively stable. More
  • Moved SimplePie File Caching to Database
    A while back, My ISP told me my backups took half a day to complete, which is too long. If anything goes wrong during that period, the process would have to start all over again, which happened quite often. The customer rep told me that my server had too many files, and even though they didn’t take up much disk space when added up, the process of copying each one of them takes a lot of time. More
  • Downtime & How to Make a Repair Job on MySQL Go Faster
    The site crashed yesterday morning at around 9am, although it’s hardly noticable until a couple hours later. I didn’t notice it until I started picking stories to feature on the homepage. Whenever i tried to feature an article, it would stop the site from loading up. From that, I knew that the MySQL database must be checking for corrupt tables. More


Comment On This Story