2014-12-25 Emacs Wiki Migration
I’ve been thinking about special-casing some caching: a mod_rewrite rule that says:
- if the URL has the form _emacs_page
- and there is no cookie (ie. bots, just readers)
- and there is an if-none-match header (from nginx, I presume?)
- and its value matches the “default”
- return 304 without invoking the wiki
So, what’s the “default”?
sub DoBrowseRequest {
...
print $q->header(-status=>'304 NOT MODIFIED') and return if PageFresh(); # return value is ignored
...
}
sub PageFresh { # pages can depend on other pages (ie. last update), admin status, and css
return 1 if $q->http('HTTP_IF_NONE_MATCH') and GetParam('cache', $UseCache) >= 2
and $q->http('HTTP_IF_NONE_MATCH') eq PageEtag();
}
sub PageEtag {
my ($changed, $visible, %params) = CookieData();
return UrlEncode(join($FS, $LastUpdate||$Now, sort(values %params))); # no CTL in field values
}
And what about $LastUpdate?
my $ts = (stat($IndexFile))[9]; # always stat for multiple server processes ... $LastUpdate = $ts;
So, I think that the “default” ETag should simply be the mtime of the pageidx file. We’d have to use the RewriteMap directive with an External Rewriting Program.
Yikes! I’m not sure this is really faster... I guess it would be faster if the wiki itself was no longer using mod_perl (for whatever reasons). The external rewriting program would comparing the ETag header with the pageidx mtime and return a special value which would in turn be rewritten by a second rule to “redirect” to a 304 NOT MODIFIED response...
Something to consider for later.
☯
As I’m writing this, I’m noticing that the server is slow. Check the current time, right, the five minutes before the full hour are a problem. Load reaching 6.
top - 17:59:18 up 4 days, 16:57, 1 user, load average: 5.94, 5.41, 4.04
Tasks: 20 total, 1 running, 19 sleeping, 0 stopped, 0 zombie
%Cpu(s): 98.7 us, 1.3 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 4194304 total, 1688940 used, 2505364 free, 0 buffers
KiB Swap: 1048576 total, 4416 used, 1044160 free, 1331364 cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2635 www-data 20 0 470m 122m 4704 S 101.9 3.0 42:43.65 /usr/sbin/apach
4902 www-data 20 0 434m 91m 5360 S 72.6 2.2 21:12.41 /usr/sbin/apach
1 root 20 0 10608 196 60 S 0.0 0.0 0:04.12 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd/2828
3 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khelper/2828
702 root 20 0 51560 9856 2068 S 0.0 0.2 0:11.56 munin-node
1790 messageb 20 0 29764 256 12 S 0.0 0.0 0:00.00 dbus-daemon
8703 root 20 0 71252 3664 2872 S 0.0 0.1 0:00.02 sshd
8707 alex 20 0 71252 1720 924 S 0.0 0.0 0:00.00 sshd
8708 alex 20 0 21256 4096 1712 S 0.0 0.1 0:00.05 bash
8723 alex 20 0 23120 1612 1188 R 0.0 0.0 0:00.00 top
15874 root 20 0 71192 5168 1620 S 0.0 0.1 1:20.36 fail2ban-server
15876 root 20 0 22260 908 672 S 0.0 0.0 0:06.63 gam_server
19427 root 30 10 12252 956 792 S 0.0 0.0 0:00.00 rsync
20367 root 20 0 49728 4624 712 S 0.0 0.1 0:19.49 rsyslogd
21949 root 20 0 49892 1236 628 S 0.0 0.0 0:00.81 sshd
22815 root 20 0 20368 496 364 S 0.0 0.0 0:01.23 cron
25118 root 20 0 122m 10m 3932 S 0.0 0.3 0:01.28 /usr/sbin/apach
27076 root 20 0 72564 2024 732 S 0.0 0.0 0:09.69 sendmail-mta
29022 root 20 0 42984 2976 2148 S 0.0 0.1 0:18.03 monit
A few minutes later load reached 7. And my processes aren’t busy.
top - 18:01:45 up 4 days, 16:59, 1 user, load average: 6.65, 5.91, 4.43
Tasks: 24 total, 2 running, 22 sleeping, 0 stopped, 0 zombie
%Cpu(s): 97.2 us, 0.9 sy, 1.7 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.2 st
KiB Mem: 4194304 total, 1726856 used, 2467448 free, 0 buffers
KiB Swap: 1048576 total, 4416 used, 1044160 free, 1331376 cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4902 www-data 20 0 437m 108m 5384 S 61.6 2.7 22:46.97 /usr/sbin/apach
9105 munin 30 10 140m 23m 5936 R 3.3 0.6 0:02.26 munin-graph
1 root 20 0 10608 196 60 S 0.0 0.0 0:04.12 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd/2828
3 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khelper/2828
702 root 20 0 51560 9856 2068 S 0.0 0.2 0:11.57 munin-node
1790 messageb 20 0 29764 256 12 S 0.0 0.0 0:00.00 dbus-daemon
8703 root 20 0 71252 3664 2872 S 0.0 0.1 0:00.02 sshd
8707 alex 20 0 71252 1720 924 S 0.0 0.0 0:00.00 sshd
8708 alex 20 0 21256 4096 1712 S 0.0 0.1 0:00.05 bash
8723 alex 20 0 23120 1612 1188 R 0.0 0.0 0:00.06 top
8734 root 20 0 33032 1160 836 S 0.0 0.0 0:00.00 cron
8738 munin 20 0 10708 1388 1200 S 0.0 0.0 0:00.00 sh
8742 munin 20 0 10716 1392 1192 S 0.0 0.0 0:00.00 munin-cron
15874 root 20 0 71192 5168 1620 S 0.0 0.1 1:20.38 fail2ban-server
15876 root 20 0 22260 908 672 S 0.0 0.0 0:06.64 gam_server
19427 root 30 10 12252 956 792 S 0.0 0.0 0:00.00 rsync
20367 root 20 0 49728 4624 712 S 0.0 0.1 0:19.49 rsyslogd
21949 root 20 0 49892 1236 628 S 0.0 0.0 0:00.81 sshd
22815 root 20 0 20368 496 364 S 0.0 0.0 0:01.23 cron
25118 root 20 0 122m 10m 3932 S 0.0 0.3 0:01.28 /usr/sbin/apach
27076 root 20 0 72564 2024 732 S 0.0 0.0 0:09.70 sendmail-mta
29022 root 20 0 42984 2976 2148 S 0.0 0.1 0:18.03 monit
#Emacs #Wikis #Oddmuse #mod perl #Apache #DevOps #Administration
Comments
(Please contact me if you want to remove your comment.)
⁂
So I’m thinking, why don’t you run some small benchmark (with apache turned off) to see how much of the CPU you’ve got? Or maybe even IO benchmark?– AlexDaniel 2014-12-26 11:00 UTC
---
Yeah. I guess I was hoping that munin does this, effectively. I’ll have to check the plugins currently enabled and check whether they do what I think they do.
– Alex Schroeder 2014-12-26 20:19 UTC