CentOS Under Tektonic.net

From DuncanWiki

Jump to: navigation, search

How much is my monthly hosting bill? $15... and what am I getting for my money? Email with server side spam filtering, this wiki, an Apache VirtualHost of my random stuff, and plenty of cycles to compile software as necessary.

Contents

Tektonic.net

Tektonic.net is basically the cheapest game I could find... there are certainly downsides to their services.

  • Their admins have full access to your process table, file system & everything that goes with that
  • I can find myself battling for I/O with other users of the same physical hardware
  • A handful of monthly emails during the auto-renew period

My Server Configuration

Keep in mind that this is all shared resources, I don't get to monopolize the wicked-awesome CPU & who knows how many other people are using the same physical disks. If someone starts thrashing the disks I suffer immediately.

  • Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz
  • 294MB RAM
  • 13GB RAID-10 disk
  • NO SWAP SPACE

Major Caveat

They watch your process table, I was downloading a CentOS torrent & had an email kicked my way. Since this is a virtual host you don't have the privacy that's typically afforded dedicated hardware. I wouldn't run a business on a Tektonic virtual machine, but my hobby site is just fine. I guess with something like thttpd running it'd make a pretty decent high-volume image server if you bought the higher outbound bandwidth package.

My Software Configuration

With abysmal specifications (except for CPU) such as this I had to get creative with the services I run on the machine.

Apache

Disable Indexing

You can disable indexes on a per-site basis with :

Options -Indexes

With my configuration I just decided to comment out all Indexing options in my /etc/httpd/conf/httpd.conf

Static Indexes

I found a script that did a decent job of creating indexes and greatly improved upon it (including parallelization & improving how attractive the html was).

You can download it at http://files.duncanbrown.org/linux/scripts/autoindex

Basic command syntax examples are :

autoindex /var/www/html

or to create index files for the current directory :

autoindex

or

find /var/www/html -type -d exec autoindex {} \;

Limit Number Of Servers

StartServers            1   
MinSpareServers         1   
MaxSpareServers         4   

Limit Life Of Children

Apache children process can be memory hogs. I simply limited their lifespan with the following directives :

ThreadsPerChild         25  
MaxRequestsPerChild     10  

PHP

I lowered the memory_limit to 30 megabytes in /etc/php.ini :

memory_limit = 30M      ; Maximum amount of memory a script may consume
  • Limit max memory usage

MySQL

I've limited my memory usage by scaling back most of MySQL's memory usage. Here's a copy of my /etc/my.cnf :

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
old_passwords=1
key_buffer = 16K 
max_allowed_packet = 1M
table_cache = 4 
sort_buffer_size = 64K 
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K 

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[mysqldump]
quick
max_allowed_packet = 16M 

[isamchk]
key_buffer = 8M
sort_buffer_size = 8M

[myisamchk]
key_buffer = 8M
sort_buffer_size = 8M

Sendmail

  • children

Spam Assassin

Limit the number of children spawned in /etc/sysconfig/spamassassin :

CHILDREN=2

My Process Table

As you can see below, I have an extremely limited number of services running on my virtual machine. Since Tektonic.net doesn't allow their virtual hosts swap space, I need to ensure that I have plenty of free memory so processes don't start seizing.

(duncan@duncanbrown:~)$ free
             total       used       free     shared    buffers     cached
Mem:        301056     235876      65180          0          0          0
-/+ buffers/cache:     235876      65180
Swap:            0          0          0
(duncan@duncanbrown:~)$ ps auxwwf
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.2  10324   696 ?        Ss   Sep03   0:02 init [3]      
root     21916  0.0  0.2  12584   644 ?        S<s  Sep03   0:00 /sbin/udevd -d
root     29767  0.0  0.1   5888   600 ?        Ss   Sep03   0:00 syslogd -m 0
root     29879  0.0  0.1   3784   424 ?        Ss   Sep03   0:00 klogd -x
root     30564  0.0  0.4  60520  1220 ?        Ss   Sep03   0:00 /usr/sbin/sshd
root     10045  0.0  1.0  85868  3188 ?        Ss   01:33   0:00  \_ sshd: duncan [priv]
duncan   10098  0.0  0.8  86680  2516 ?        S    01:33   0:00      \_ sshd: duncan@pts/0
duncan   10100  0.0  0.4  10912  1464 pts/0    Ss   01:33   0:00          \_ -bash
duncan   10198  0.0  0.3  19308   916 pts/0    S+   01:33   0:00              \_ /usr/bin/screen -DAR
root     31996  0.0  0.3  10772  1152 ?        S    Sep03   0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid
mysql     1370  0.0 10.3 190556 31044 ?        Sl   Sep03   0:12  \_ /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock
root     14078  0.0 15.3 104552 46268 ?        Ss   Sep03   0:05 /usr/bin/spamd -d -c -m1 -H -r /var/run/spamd.pid
root     18186  0.0 17.6 111540 53264 ?        S    Sep03   0:06  \_ spamd child
root     16091  0.0  0.7  71016  2388 ?        Ss   Sep03   0:02 sendmail: accepting connections
smmsp    16161  0.0  0.5  57608  1768 ?        Ss   Sep03   0:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root     20127  0.0  4.5 319760 13796 ?        Ss   Sep03   0:05 /usr/sbin/httpd
apache   26075  0.0  9.5 338012 28676 ?        S    Sep03   0:00  \_ /usr/sbin/httpd
apache   17686  0.0  9.6 338356 28960 ?        S    Sep03   0:01  \_ /usr/sbin/httpd
apache   12172  0.0  9.6 338216 28916 ?        S    00:00   0:00  \_ /usr/sbin/httpd
apache   27779  0.1  9.1 336784 27632 ?        S    02:08   0:00  \_ /usr/sbin/httpd
root     20185  0.0  0.3  19676  1140 ?        Ss   Sep03   0:00 crond
root     20228  0.0  0.4  49660  1416 ?        Ss   Sep03   0:00 squid -D
squid    20231  0.0  2.1  52392  6452 ?        S    Sep03   0:09  \_ (squid) -D
squid    31995  0.0  0.0   3624   244 ?        Ss   Sep03   0:00      \_ (unlinkd)
root      5651  0.0  0.1  18696   456 ?        Ss   Sep03   0:00 /usr/sbin/atd
root      5669  0.0  0.1  46648   508 ?        Ss   Sep03   0:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -n 2
root      5765  0.0  0.0  46648   292 ?        S    Sep03   0:00  \_ /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -n 2
duncan    9335  0.0  5.4  34596 16284 ?        Ss   Sep03   0:01 /usr/bin/SCREEN -DAR
duncan    9336  0.0  0.4  11044  1480 pts/1    Ss   Sep03   0:00  \_ /bin/bash
duncan   25895  0.0  0.5  11040  1536 pts/2    Ss+  01:49   0:00  \_ /bin/bash
duncan   32240  0.0  0.5  11044  1536 pts/3    Ss   01:56   0:00  \_ /bin/bash
duncan   16267  0.0  0.2  10432   808 pts/3    R+   02:15   0:00  |   \_ ps auxwwf
duncan   30472  0.0  0.4  11040  1484 pts/4    Ss+  01:56   0:00  \_ /bin/bash
duncan    1793  0.0  0.5  11044  1512 pts/5    Ss+  02:03   0:00  \_ /bin/bash
Personal tools