2014-12-22 Emacs Wiki Migration

(Continued from yesterday.)

yesterday

Well... I considered making this website mod_perl in order to reduce load. This morning it was incredibly high again. When I tried it, however, I ran into problems. Error messages indicated that my script wouldn’t compile. Something about `ModPerl::Registry` not being available (eventhough it seemed to work for Emacs Wiki), or links on my site pointing to Emacs Wiki. Something was getting mixed up? Does mod_perl not work when used for more than one script in a virtual hosting environment? I rolled back my changes and went to do whatever one does a few years before the year. As I came back, the situation doesn’t seem too bad:

https://alexschroeder.ch/pics/15459696234_a9351a5831_o.png

I’d prefer load around 2, but at least the site responds, most of the time.

Well, service continues to be lousy and I’m practically out of ideas. The next step looks like hacking Oddmuse to try and reduce file accesses and hits.

In the mean time, here’s the top of Apache’s *server-info*.

Server Version: Apache/2.2.22 (Debian) mod_ssl/2.2.22 OpenSSL/1.0.1e mod_perl/2.0.7 Perl/v5.14.2
Server Built: Jul 24 2014 15:34:03

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Current Time: Tuesday, 23-Dec-2014 00:25:10 CET
Restart Time: Tuesday, 23-Dec-2014 00:23:07 CET
Parent Server Generation: 0
Server uptime: 2 minutes 3 seconds
Total accesses: 482 - Total Traffic: 2.2 MB
CPU Usage: u83.27 s1.06 cu18.66 cs0 - 83.7% CPU load
3.92 requests/sec - 18.0 kB/second - 4705 B/request
9 requests currently being processed, 91 idle workers

W________________K_____________R_W_______K_K_W__________________
________________R__________________K............................
................................................W...............
................................................................
............................................

Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current process

That doesn’t really look very busy. So perhaps file access is the new bottle neck?

If you know some Perl, and if you know mod_perl, and you feel like you could help, please contact me!

contact me

The current setup uses a Linux OpenVZ / SolusVM VPS in Switzerland with 4096 MB RAM and 2 vCores (shared Dual Intel Xeon), 500 GB HDD (practically unused) Speicherplatz, with Debian Wheezy.

Linux OpenVZ / SolusVM VPS

4096 MB RAM and 2 vCores

The Apache setup I mentioned previously:

<IfModule mpm_worker_module>
    StartServers          2
    ServerLimit           3
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit         100
    ThreadsPerChild     100
    MaxClients          300
    MaxRequestsPerChild  10000
</IfModule>

The virtual server setup:

<VirtualHost *:80>
    ServerAdmin alex@emacswiki.org
    <Directory />
        Options None
        AllowOverride None
        Order Deny,Allow
        Deny from all
    </Directory>
    ServerName www.emacswiki.org
    ServerAlias emacswiki.org
    DocumentRoot /home/alex/emacswiki.org
    <Directory /home/alex/emacswiki.org>
        Options ExecCGI Includes Indexes SymLinksIfOwnerMatch
	AddHandler cgi-script .pl
        AllowOverride All
        Order Allow,Deny
        Allow from all
    </Directory>
    <Files emacs.pl>
       Options ExecCGI SymLinksIfOwnerMatch
       SetHandler perl-script
       PerlHandler ModPerl::Registry
    </Files>
    RewriteLog "/home/alex/logs/emacswiki.org/rewrite.log"
    RewriteLogLevel 0
    CustomLog /home/alex/logs/emacswiki.org/access.log combined
    ErrorLog  /home/alex/logs/emacswiki.org/error.log
    # LogLevel debug
    CustomLog /var/log/apache2/access.log vhost_combined
    ServerSignature On
</VirtualHost>

I run monit and munin for monitoring.

And now we’re getting into Oddmuse details. If you need more information in order to setup up a test environment, I’ll be happy to provide anything you need.

#! /usr/bin/perl
package OddMuse;
use CGI;
$q = new CGI;
$RunCGI = 0;
$UseConfig = 0; # no config!
$DataDir = '/home/alex/emacswiki';
if (not $config_loaded) {
  do '/home/alex/emacswiki.org/current.pl';
  do '/home/alex/emacswiki/modules/concat.pl';
  do '/home/alex/emacswiki/config';
  $config_loaded = 1;
}

1. make sure traces of other language configs disappear
%Translate=();
$HomePage    = "SiteMap";
$RCName      = 'RecentChanges';
@UserGotoBarPages = ($HomePage, 'Search',
		     'ElispArea', 'HowTo', 'Glossary',
		     $RCName, 'News', 'Problems', 'Suggestions');
$EditNote = '<p>Please make sure you contribute only your own work. IP numbers are made available via the page history. If you want to keep it a secret, you need to use <a href="http://www.torproject.org/">Tor</a>. See <a href="/emacs/TextFormattingRules">TextFormattingRules</a> for how to format text. See <a href="/emacs/StyleGuide">StyleGuide</a> for the suggested writing style on this wiki.</p>';

1. language specific files should only set variables, never redefine subroutines
$ConfigFile = "$DataDir/config-en";
1. my $requested_language = "da, en-gb;q=0.8, en;q=0.7";
my $requested_language = $q->http('Accept-language');
my @languages = split(/ *, */, $requested_language);
my %Lang = ();
foreach $_ (@languages) {
  my $qual = 1;
  $qual = $1 if (/q=([0-9.]+)/);
  $Lang{$qual} = $1 if (/^([-a-z]+[a-z])/);
}
my @prefs = sort { $b <=> $a } keys %Lang;
1. my $html = "input: $requested_language" . "\nResult: " . join(', ', map { "$_ ($Lang{$_})" } @prefs);
1. print header, start_html, pre($html), end_html; exit;
foreach $_ (@prefs) {
  if (-r "$DataDir/config-$Lang{$_}") {
    $ConfigFile = "$DataDir/config-$Lang{$_}";
    last;
  }
}
do $ConfigFile;
1. Do the wiki
DoWikiRequest();

(Continued tomorrow.)

tomorrow

​#Emacs ​#Wikis ​#Oddmuse ​#mod perl ​#Apache ​#devops ​#Administration

Comments

(Please contact me if you want to remove your comment.)

Completely unrelated, but if the majority of the traffic is anonymous, I would suggest installing Varnish

– Anonymous 2014-12-23 19:06 UTC

---

I’m not sure. In my .htaccess, I already provide for long browser-side caching of static files:

ExpiresActive On
ExpiresDefault "access plus 1 hours"
ExpiresByType image/png "access plus 3 days"
ExpiresByType image/jpeg "access plus 3 days"
ExpiresByType image/svg+xml "access plus 3 days"
ExpiresByType text/css "access plus 3 days"

And the wiki itself uses ETags the way they were meant to be used, I think. See the wiki page on caching, if you’re interested. It’s true that returning the 304 code requires the wiki code to run, but I’m still saving on all the rendering. It’s worth a try, I guess. A short skimming of an intro page I found made me think that using it for wiki pages is going to involve some more work. Do you have some detailed instructions somewhere, or can you help in configuring Varnish for Oddmuse? The Varnish wiki page on ETags looks intimidating.

caching

an intro page

Varnish wiki page on ETags

– Alex Schroeder 2014-12-23 20:33 UTC