Blog

  • Groundhog Day Resolutions

    February 1, 2007
    NOTE: You can find all the recent Groundhog Day Resolutions post (still running in 2016!) under the ghdr tag!. Have fun!


    Groundhog Day is one of my favorite holidays, though calling it a “holiday” may be a stretch for most people. Last year I marked the day by reading up on its history, and discovered it is actually quite an old holiday dating back to Roman times. Also, the whole prediction of “six more weeks of winter” is actually a joke of the “Heads I win, Tails you Lose” variety; the Spring Equinox happens to fall approximately six weeks after February 2nd, and technically winter is over no matter what. As fascinating as that is, my favorite part of the holiday is the mental image of a groundhog telling the future, and it’s just the sort of folksy holiday that reaffirms that we don’t have to take life too seriously. For me, Groundhog Day is a reminder to maintain a flexible, magical perspective on life.

    For years I’ve struggled to think of a way to properly celebrate Groundhog Day. Even as a child, I was disappointed by the lack of spectacle with which people marked the day. There are no cards, candies, chocolates, or special dances. We’re lucky to maybe get a wry chuckle from the local news, perhaps a quick clip of Punxsutawney Phil doing his thing for the camera. But where’s the pre-game show? Where’s the post-shadow analysis on CNN? Why doesn’t the stock market tremble in the aftermath of Phil’s mighty labor of prognostication? Something just isn’t right here…to most, it’s just an ordinary day, about as noteworthy as finding a quarter in the washing machine.

    Bill Murray gave Groundhog Day a much-needed boost with the eponymous movie back in 1993, and it’s been suggested to me that an appropriate way to observe the day is to indulge in his cinematic back-catalog. A reverent viewing with close family and friends would at least be respectful. However, I’ve had a revelation about the New Year, and have decided to move my resolution making to Groundhog Day. It makes perfect sense! No, really!

    (more…)

    Read more
    DSri Seah
  • Configuring a Media Temple (dv) Base for WordPress

    January 31, 2007

    This article applies to an older version of the Media Temple (dv) service from 2007. You may want to check Media Temple’s knowledge base for updated information.

    I’m running a (dv) Base system from Media Temple, which is their 256MB version. This is their lowest-end server configuration, which is actually a virtual server sharing the same hardware.

    As my blog has grown in popularity, when I switched over I got enough traffic to overwhelm the server. It turned out that the base configuration isn’t tuned to work within the guaranteed 256MB of memory allocated. It’s configured to run on a considerably larger server, and grabs extra memory as needed if it’s available from the global memory pool. This is all fine and dandy when memory is available, but if it ISN’T, the server will start to chug.

    After making the following tweaks to my server setup, one of my articles was dugg and the server was hit by 2750 pageloads per hour for a few hours. This is a pretty significant amount of traffic, and the server had no problems staying up. In fact, it barely broke a sweat. Keep in mind though that in addition to the server tweaks below, I also had optimized my wordpress installation with WP-Cache, which reduces server load significantly. You can read more about this in WordPress and Shared Hosting.

    Anyway, here’s what I’ve done to get my DV in line. I’ll write about the WordPress issues a little later. If this article convinces ya to get a (dv), refer my site when you order so I get a little reward from Media Temple :-)

    Check for Memory Faults

    The virtual server is a product called “Virtuozzo”, and there’s a special file that tells you how much memory you’re allowed to use. When you exceed that amount of memory, a fault is generated. Ideally, you don’t want any faults.

    To check up on this, you can use Plesk (under Virtuozzo) or login to your server and type cat /proc/user_beancounters into the command shell. The column that’s of most immediate use to you is failcnt, which tells you how many times a program has tried to get some memory to do something, but wasn’t able to do so. The values should all be 0.

    I’ll fill this section in a little later, because it’s kind of tricky to understand and I don’t entirely get it. Here’s a cheesy script I use to constantly monitor the user_beancounters to see if they’re going up (I just open a second shell window):

    #!/bin/sh
    while true ; do cat /proc/user_beancounters ; sleep 1 ; done
    

    When you run this script, it just cats the output every second (see image). If you’re monitoring other parts of the server, you might see some overall patterns in what seems to be causing the memory usage. There’s some more information at the very end of this post (with screenshots) to help orient you.

    Apache Configuration

    The default configuration for Apache allowed too many instances of httpd to spawn. Since each instance takes between 20MB and 40MB, you don’t want more than your available memory to be created. If I figure on allowing 128MB available out of my 256MB, and each Apache instance takes 20MB, that means I can’t have too many of them active at once. In actuality, the memory usage reported by ps aux under the VSZ and RSS headings isn’t the real picture of memory usage (see this article for some insight into this), so I can actually have more instances. I experimentally determined that 20 seemed to be enough without pushing the server too hard.

    The pertinent settings are in the prefork section of /etc/httpd/conf/httpd.conf. Make sure you save a backup of the file. Here’s what my prefork section looks like (SAVE A BACKUP BEFORE YOU EDIT!)

    <ifModule prefork.c>
    StartServers 1
    MinSpareServers 1
    MaxSpareServers 3
    ServerLimit 20
    MaxClients 20
    MaxRequestsPerChild  4000
    </ifModule>
    

    UPDATE: On the week of August 21, 2007, I noticed that my memory allocation was exceeded regularly by about 100MB or so. It seems that the way (MT) is calculating physical memory use is also taking virtual memory into account. I had to drop ServerLimit from 20 to 6 to maintain responsiveness. I have a ticket open to see if this is a bug or not (virtual memory is disk-based, so you’d think it wouldn’t count against your physical memory allocation). :END UPDATE

    UPDATE:Chris McKee points out that Media Temple has a performance tuning knowledge base article with some recommendations for the Apache configuration. My settings are much more conservative, designed to avoid memory swapping altogether.

    I also disabled modules that I wasn’t using by commenting them out. I reduced the memory footprint of each httpd instance by a bit. Every bit helps! The lines with the # in front are disabled modules.

    LoadModule access_module modules/mod_access.so
    LoadModule auth_module modules/mod_auth.so
    # LoadModule auth_anon_module modules/mod_auth_anon.so
    # LoadModule auth_dbm_module modules/mod_auth_dbm.so
    # LoadModule auth_digest_module modules/mod_auth_digest.so
    # LoadModule ldap_module modules/mod_ldap.so
    # LoadModule auth_ldap_module modules/mod_auth_ldap.so
    LoadModule include_module modules/mod_include.so
    LoadModule log_config_module modules/mod_log_config.so
    LoadModule env_module modules/mod_env.so
    # LoadModule mime_magic_module modules/mod_mime_magic.so
    # LoadModule cern_meta_module modules/mod_cern_meta.so
    LoadModule expires_module modules/mod_expires.so
    # LoadModule deflate_module modules/mod_deflate.so
    LoadModule headers_module modules/mod_headers.so
    # LoadModule usertrack_module modules/mod_usertrack.so
    LoadModule setenvif_module modules/mod_setenvif.so
    LoadModule mime_module modules/mod_mime.so
    # LoadModule dav_module modules/mod_dav.so
    # LoadModule status_module modules/mod_status.so
    LoadModule autoindex_module modules/mod_autoindex.so
    # LoadModule asis_module modules/mod_asis.so
    # LoadModule info_module modules/mod_info.so
    # LoadModule dav_fs_module modules/mod_dav_fs.so
    LoadModule vhost_alias_module modules/mod_vhost_alias.so
    LoadModule negotiation_module modules/mod_negotiation.so
    LoadModule dir_module modules/mod_dir.so
    # LoadModule imap_module modules/mod_imap.so
    LoadModule actions_module modules/mod_actions.so
    # LoadModule speling_module modules/mod_speling.so
    LoadModule userdir_module modules/mod_userdir.so
    LoadModule alias_module modules/mod_alias.so
    LoadModule rewrite_module modules/mod_rewrite.so
    # LoadModule proxy_module modules/mod_proxy.so
    # LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
    # LoadModule proxy_http_module modules/mod_proxy_http.so
    # LoadModule proxy_connect_module modules/mod_proxy_connect.so
    # LoadModule cache_module modules/mod_cache.so
    LoadModule suexec_module modules/mod_suexec.so
    # LoadModule disk_cache_module modules/mod_disk_cache.so
    # LoadModule file_cache_module modules/mod_file_cache.so
    # LoadModule mem_cache_module modules/mod_mem_cache.so
    # LoadModule cgi_module modules/mod_cgi.so
    LoadModule logio_module /usr/lib/httpd/modules/mod_logio.so
    

    After you make these changes, type apachectl configtest to make sure you haven’t screwed something up. If you get the Syntax OK go-ahead, then apachectl restart will restart the server and reread the configuration.

    Note: Your website might actually use some of the modules that I’m not using, so be careful.

    Note: ps -A -o pid,vsz,rss,pmem,time,comm shows memory usage (VSZ and RSS) roughly, though it’s not really accurate.

    SMTP connections

    SMTP is used to receive mail addressed to mailboxes on your server. It’s also used to send mail to other people from your email account.

    By default, the number of incoming SMTP connections was set to “unlimited”. When I was getting hammered by spam, this created a LOT of simultaneous connections, each of which took up memory. I limited the number of instances to 10 by editing /etc/xinetd.d/smtp_psa, from the default of 0 (unlimited).

    I also noticed that when a secure SMTP connection (SMTPS) occured, the SMTPS daemon would use 100% CPU. I don’t use secure SMTP, so I denied all SMTPS connections to prevent spammers connecting to the secure port from creating this problem. That file is /etc/xinetd.d/smtps_psa.

    After you make these changes, type /etc/init.d/xinetd restart to tell the server to re-read and use the new configuration information.

    POP3 and IMAP SSL

    Since I don’t use SSL for IMAP or POP (these are services that email programs use to download your mail), I disabled these scripts as well by commenting out the lines that start with report_action "Starting imap-ssl" and report_action "Starting pop3-ssl". I will have to look back at these later to see if they really make a difference.

    To restart the services, type /etc/init.d/courier-imap restart.

    MySQL Configuration

    Although I wasn’t sure if MySQL was a problem, I decided to configure it to run in a smaller memory footprint. I’m not an expert in MySQL configuration, so I just used the “medium” memory configuration as a starting point. You can find the my-medium.cnf file, suitable for a 64MB instance, in /usr/share/doc/mysql-server-4.1.20/. The changes I made were in the [mysqld] section of the file /etc/my.cnf

    [mysqld]
    set-variable=local-infile=0
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    # Default to using old password format for compatibility with mysql 3.x
    # clients (those using the mysqlclient10 compatibility package).
    old_passwords=1
    skip-bdb
    
    set-variable = max_allowed_packet=1M
    set-variable = key_buffer=16M
    set-variable = table_cache=64
    set-variable = sort_buffer=512K
    set-variable = net_buffer_length=8K
    
    set-variable = myisam_sort_buffer_size=8M
    

    I basically added the set-variable commands.

    When I was importing my WordPress database, I also had to increase max_allowed_packet to 16MB. It turned out that there was an inefficiency in my WordPress setup that actually was the source of this problem: The Tan Tan Reports plugin created a very large entry in the wp-options database table. I removed the plugin and its data from the wordpress database table and I was able to reduce it back to 1MB. This was very important from a memory usage perspective too; MySQL allocates extra memory for inter-process communication (like, between MySQL and WordPress), and this caused memory failures in the user_beancounters!

    After you make these changes, type /etc/init.d/mysqld restart to reload the MySQL configuration.

    Additional Optimizations

    There are some additional things I did, like disabling spamassassin (21MB), limiting the number of plesk connections (another 30MB), and disabling named (1MB). You can read about these additional optimizations over here.

    Screenshots

    See this page for some screens and descriptions of how I am monitoring memory usage the old-fashioned way.

    Read more
    DSri Seah
  • 5 Things You Probably Didn’t Know About Me

    January 31, 2007

    I’ve been a slacker on this meme, having been tagged months ago by Katy, Grigor, and now Senia. So without further delay, here are five things you probably didn’t know about me, but maybe could have guessed.

    1. I like brightly-colored beverages. The more artificial-looking, the more I want to try it. This doesn’t apply to mixed drinks though…I don’t really like alcohol.
    2. I can’t hear lyrics in music, but I can hear orchestral music in my head. Sometimes I lie awake at night arranging music in my head, wondering if I’m really hearing it or if I’m just deluding myself. One of these days I’ll take some music lessons…the problem is that the musical instruction I’ve had has been based on rote memorization and acceptance that there’s just one way to do it right. As you can imagine, that makes me itch like crazy. I just ordered a “chord piano” course to see if this works; it’s all based on patterns, which is up my alley. I hope. My goal is to be able to play blues piano someday :-)

    3. I hate shellfish. Shrimp, lobster, crab…yuck! They’re bugs from the sea!!! Yet, I seem to end up living in places where seafood is plentiful. Maybe I should move to Texas.

    4. I have an uncanny ability to spot half-point misalignments in type from 10 paces. Yet I can not optically kern a line of text to save my life.

    5. I’m a hard-boiled romantic. I think that means that while I recognize that ethics and morality are often relative, and the world is kind of a tough place to exist, deep down I want things to be clear and people to feel comfortable being themselves without fear of being mocked. Whatever I can do to make that happen seems like the right thing to do. Maybe this last one is actually obvious from my writing, I’m too close to really see it. It’s something more that I feel, very deeply and intimately.

    <

    p>Since this is a meme, I’m going to tag the people who happened to leave a comment on my blog one year ago today. As soon as I figure out how to find out who those people are :-)

    Don’t forget too, that Groundhog’s Day Resolutions are coming up! I’ll be posting mine tomorrow.

    Read more
    DSri Seah
  • Flickr and Moo Mini Cards

    January 30, 2007

    Moo Mini Cards I have a paypal account that I use as my “research” fund, and the latest purchase is these Mini Cards from Moo. They were all the rage last year, when Moo was offering free sets of 10 for a limited time. Since I have a bunch of pictures now in my Flickr account, I thought I’d give the service a try.

    Moo Mini Cards BoxMoo Mini Cards BoxMoo Mini Cards Box Moo is based in the U.K., so my $20 order of 100 cards took a few days to get here via Royal Mail. The cards themselves are quite small, 2 3/4″ by 1 1/8″ inches, or about the size of a squattish stick of gum. They’re nice and stiff, coated with that nice matte finish…very nice. They all come packaged in a sturdy plastic box.

    I printed these via the Flickr photo sharing service. The Moo printing option allows you to pick 100 different pictures so they’re all different. Since SXSW is coming up, I thought I’d have a bunch of these on hand to give to people in case they needed my mobile number; the conference was kind of nuts last year with all the people running around, and I’ve been thinking of ways to make it a little easier to keep track of everything. This year I plan to be prepared!

    Moo Mini Cards BoxThe flip side of the card has some customizable contact information, and a URL to the actual photo. They’re a bit pricey at 20 cents per card. It would have been cheaper to get some custom printed business cards of comparable quality online (it’s shocking how cheap this is now), but I wouldn’t have been able to get a different photo on each card on such nice paper stock. Plus, the experience of picking a card itself will become part of the fun. When faced with a selection, how will people decide what to pick? What will that say about them? If I were to break up the 100 cards into 10 groups of 10 photos, I might be able to make some kind of psycho-analytical tool, maybe create a mini card game of some kind. These mini cards have a powerful totemic presence that’s very tempting to apply in a creative business context.

    Anyway, the Moo Minicards get a thumbs-up for me! I believe they’re only available with Flickr photos, so you’ll need an account (free ones are available). You can browse my flickr account to see what I’ve been doing over there, if you haven’t clicked on the photos in the sidebar before.

    Read more
    DSri Seah
  • Play “Guess the Form”

    January 29, 2007

    I’d recently corresponded with Dana Ditomaso, who had contacted me about getting the unlock code for the ever-mysterious Resource Task Quantizer. She wanted to work something up for her design studio, Liquidesign, up in Canada. Since I’m interested in seeing how people adapt the forms for their own use, I said sure. Later, I got a set of really cool forms that she’d expanded to keep track of the ongoing jobs…it was very gratifying to see these design ideas put into the context of a working studio, much in the way the Blue Flavor guys have with their nifty PCEO-inspired timesheets. Makes me feel useful :-)

    Now, I happen to be in a project and resource planning kind of mood, so I combined elements that I like into a form based on the Resource Task Quantizer. While I like the intention between the two-piece Resource Task Quantizer and Scheduler, it’s really too cumbersome; this is the point where software starts to make sense to ease the burden. The last thing I want to do is spend more than a few seconds fiddling with a form. The whole point is to make the information easy to enter and easy to scan, to gain large efficiencies for relatively little (but important) effort. That’s a golden moment, and I try to design it into everything I make.

    Project ProjectorI happen to be in a experimental mood too, so instead of making a form and releasing it the usual way, I’m going to release this early design. It’s actually a 3rd draft, but I’m throwing out a picture of it to see what you think it does.

    (more…)

    Read more
    DSri Seah