Subject: Re: [vserver] Re: [Freedombox-discuss] A software architecture for the FreedomBox
From: Gordan Bobic <gordan@bobich.net>
Date: Wed, 13 Apr 2011 23:27:19 +0100

On 13/04/2011 21:31, Eugen Leitl wrote:
> ----- Forwarded message from Jonas Smedegaard<dr@jones.dk>  -----
>
> From: Jonas Smedegaard<dr@jones.dk>
> Date: Wed, 13 Apr 2011 18:20:58 +0200
> To: freedombox-discuss@lists.alioth.debian.org
> Subject: Re: [Freedombox-discuss] A software architecture for the FreedomBox
> User-Agent: Mutt/1.5.21 (2010-09-15)
> Reply-To: freedombox-discuss@lists.alioth.debian.org
>
> On 11-04-13 at 05:49pm, Eugen Leitl wrote:
>> On Wed, Apr 13, 2011 at 05:06:23PM +0200, Rob van der Hoeven wrote:
>>
>>> One of the first things you have to do when building a system like
>>> the FreedomBox is figure out the software architecture. I have come
>>> up with an interesting architecture that is made of Linux Containers
>>> (Virtual
>>
>> Using Linux vserver guests for service separation (jails on steroids)
>> is an excellent idea, actually.
>
> I find it interesting, but am sceptical: I believe each jail consume
> separate memory for their libraries - i.e. cannot benefit from shared
> libraries.  So I worry about memory consumption.
>
> On a related note I want to keep low the number of used library
> environments - e.g. try to aim for...
>
>    * only one of libssl or gnutls
>    * fewest possible of Python, Perl, Bash, Ruby, PHP
>
> ...especially for things running as daemons, but also for e.g.
> cron-triggered scripts, as even temporary required memory might not be
> available.

You probably need to look into:
vserver <guestname> hashify

This will safely copy-on-write hard-link all identical files (make sure 
you un-prelink everything and remove prelink!), including shared 
libraries, so if you have 10 guests, you'll only get one instance of 
glibc mmap-ed instead of 10.

This will also reduce cache pressures since you only cache the file once 
rather than for each guest instance.

> I notice the test system uses swap.  That is bad if using internal flash
> disks as they wear much faster that way, and swapping onto an external
> harddisk is not user-friendly: Treating it as hot-plug then not only
> risk roccupting the data files potentially being in the middle of a
> transaction but crashes the whole system!

Have you looked into ramzswap/zram? On machines with mechanical disks 
it's faster than swapping to disk, and on machines with flash disks you 
avoid hammering them.

If you are on flash, you may also be interested in some of patches/mods 
(RedHat/Fedora specific but you should be able to adapt them for other 
distros) that enable normal operation when having things that don't need 
to be persisted on tmpfs (/var/lock, /var/run, /var/log if it's not a 
server, /var/cache/yum, etc.) Normally a reboot results in 4MB+ of 
writes, and with the patches in question this gets reduced to close to 0.

Gordan