Webserver Redundacy

Tags:

On Wed, Feb 28, 2007 at 04:55:28PM +0000, Andy wrote:
> Craig Sanders wrote:
> >the easiest ways to do this is with a shared or network filesystem
> >(be careful of file locking), or in a database (let the db handle
> >locking issues).
>
> We are looking an an LVS system as discussed in this thread, with a
> centralised file-system exported over NFS.
>
> Our sessions are all PHP sessions from /var/lib/php4. If we just NFS
> export this are we going to have horrible locking problems?

it depends on how well written your code is :-)

also, i haven't worked extensively with NFS for several years now, but
it has ALWAYS had a terrible reputation for locking issues. there are
particular ways of doing NFS-safe locking (see, for example the way that
mail servers like postfix do it), and many ways of doing unsafe locking.

> Any suggestions?

my recommendation would be to avoid locking issues entirely and use
either a database or, if you dont want to install postgresql or mysql or
whatever, use memcached and store your session data in the shared memory
cache.

memached is packaged for debian.

# apt-cache show memcached php4-memcache

Package: memcached
Priority: optional
Section: web
Installed-Size: 156
Maintainer: Jay Bonci
Architecture: i386
Version: 1.1.12-1
Depends: libc6 (>= 2.3.2.ds1-4), libevent1 (>= 1.0b), perl
Suggests: libcache-memcached-perl
Filename: pool/main/m/memcached/memcached_1.1.12-1_i386.deb
Size: 33046
MD5sum: 095b820ca7b851eba3d4cc5fda9e7453
SHA1: a6798f7639a66ea19d7b88d597a60241245e8ecc
SHA256: 448117e3cda79ca1046d5c6e7553f66c95c8dc92668e0bf21f72b063ccecc6f8
Description: A high-performance memory object caching system
Danga Interactive developed memcached to enhance the speed of LiveJournal.com,
a site which was already doing 20 million+ dynamic page views per day for 1
million users with a bunch of webservers and a bunch of database servers.
memcached dropped the database load to almost nothing, yielding faster page
load times for users, better resource utilization, and faster access to the
databases on a memcache miss.
.
memcached optimizes specific high-load serving applications that are designed
to take advantage of its versatile no-locking memory access system. Clients
are available in several different programming languages, to suit the needs
of the specific application. Traditionally this has been used in mod_perl
apps to avoid storing large chunks of data in Apache memory, and to share
this burden across several machines.
Tag: devel::profiler, interface::daemon, network::server, role::program, special::not-yet-tagged, special::not-yet-tagged::m

Package: php4-memcache
Priority: optional
Section: web
Installed-Size: 68
Maintainer: Pierre Habouzit
Architecture: i386
Source: php-memcache
Version: 2.0.1-1.1
Depends: debconf (>= 0.5) | debconf-2.0, phpapi-20050606+lfs, php4-common
Filename: pool/main/p/php-memcache/php4-memcache_2.0.1-1.1_i386.deb
Size: 18460
MD5sum: 2832c776183925876a2c42f9542ec88d
SHA1: 9c98c562b421d0bc285a79cfc3bd112ea23feb13
SHA256: 5cc3e284933efb08a5b3be5bffc6a419ca83a64d7dae52a465155a1493918a72
Description: memcache extension module for PHP4
Memcached is a caching daemon designed especially for dynamic web applications
to decrease database load by storing objects in memory.
.
This extension allows you to work with memcached through handy OO and
procedural interfaces in your php4 applications.
.
documentation on: http://fr.php.net/memcache/

> PS) I also have similar questions about maildir over NFS.

maildir isn't too bad, it avoids most locking issues by having one file
per message....and most maildir capable programs are well aware of NFS
locking issues.

craig

--
craig sanders

Currently listening to: Chris Organic - The Shaman

Why does man kill? He kills for food. And not only food: frequently
there must be a beverage.
-- Woody Allen, "Without Feathers"

--

0

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Webserver Redundacy

Craig Sanders wrote:
> maildir isn't too bad, it avoids most locking issues by having one file
> per message....and most maildir capable programs are well aware of NFS
> locking issues.
>
> craig

I might sound like a dumb, but I haven't used NFS so much. In fact, I
run many small servers, and I don't have much experience of running very
big sites with multiple servers (only did multiple MySQL server for a
single web server at the moment), and when I needed it, I asked my
partners to do the job for me (as they have such experience). Could any
of you explain in details what the locking issue is, and how to avoid it?

Thomas

--

Webserver Redundacy

Something just occurred to me:

After wading through all the discussions of advertising multiple IPs via
DNS vs. using a heartbeat mechanism vs. using LVM, it strikes me that
Apache has to be appropriately configured as well.

If one is using "Listen" commands in your Apache config. file, I don't
you can simply tell set your backup (or redundant) daemon to listen on
addresses that aren't currently active. Won't Apache complain at
startup about "can't bind to address?"

Miles

--

Webserver Redundacy

Miles Fidelman wrote:
> If one is using "Listen" commands in your Apache config. file, I don't
> you can simply tell set your backup (or redundant) daemon to listen on
> addresses that aren't currently active. Won't Apache complain at
> startup about "can't bind to address?"
First, "Listen" defines the *ports* Apache listens on. BindAddress
defines the IP's

Secondly, in most stock Apache configs I've seen, they come with
"BindAddress *", and it only binds to the addresses that are active anyway.

- Joe

Webserver Redundacy

On Thu, Mar 01, 2007 at 06:15:42AM -0500, Miles Fidelman wrote:
> Something just occurred to me:
>
> After wading through all the discussions of advertising multiple IPs via
> DNS vs. using a heartbeat mechanism vs. using LVM, it strikes me that
> Apache has to be appropriately configured as well.
>
> If one is using "Listen" commands in your Apache config. file, I don't
> you can simply tell set your backup (or redundant) daemon to listen on
> addresses that aren't currently active. Won't Apache complain at
> startup about "can't bind to address?"

yes. restarting apache is one of the things that your scripts have to do
when heartbeat notices that the primary machine is down and starts the
takeover procedure.

as someone else said, using "BindAddress *" and "" works,
but not if you're doing IP-address based virtual hosts (e.g. for SSL
sites).

there are several things your scripts have to do when taking over the IP
from the dead machine (and the reverse when the primary comes back up) -
running "/etc/init.d/apache2 reload" is the least of it.

craig

--
craig sanders

Currently listening to: Shpongle - Monster Hit

"Who will say with confidence that sexual abuse is more
permanently damaging to children than threatening them
with the eternal and unquenchable fires of hell?"
[Richard Dawkins]

--

Webserver Redundacy

On Thu, Mar 01, 2007 at 04:40:33PM +0800, Thomas Goirand wrote:
> I might sound like a dumb, but I haven't used NFS so much. In fact, I
> run many small servers, and I don't have much experience of running
> very big sites with multiple servers (only did multiple MySQL server
> for a single web server at the moment), and when I needed it, I asked
> my partners to do the job for me (as they have such experience). Could
> any of you explain in details what the locking issue is, and how to
> avoid it?

IIRC, it's that flock doesn't work on NFS mounts.

the traditional way to do NFS-safe locking is to check for the existence
a FILENAME.lock file before you open it for write. if it exists then
wait until it's gone before proceeding. if/when it doesn't exist, create
the .lock file and then open your file for write. write data to it.
close it. remove the .lock file.

that's, e.g., what you have to do to write to mbox format mailboxes on NFS
filesystems.

craig

--
craig sanders

Currently listening to: Shpongle - Monster Hit

"Civilization has little to fear from educated people and brain-workers.
In them the replacement of religious motives for civilized behaviours by
other, secular motives, would proceed unobtrusively..."
[Sigmund Freud, 1927]

--

Webserver Redundacy

Am 2007-03-02 07:21:35, schrieb Craig Sanders:
> IIRC, it's that flock doesn't work on NFS mounts.

It works but not all programs (like "mc" does support it).

"flock" works fine with "mutt" and "courier" plus some other apps.

Thanks, Greetings and nice Day
Michelle Konzack
Systemadministrator
Tamay Dogan Network
Debian GNU/Linux Consultant

--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack Apt. 917 ICQ #328449886
50, rue de Soultz MSM LinuxMichi
0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)

Webserver Redundacy

Hello Thomas,

Am 2007-03-01 16:40:33, schrieb Thomas Goirand:
> I might sound like a dumb, but I haven't used NFS so much. In fact, I
> run many small servers, and I don't have much experience of running very
> big sites with multiple servers (only did multiple MySQL server for a
> single web server at the moment), and when I needed it, I asked my
> partners to do the job for me (as they have such experience). Could any
> of you explain in details what the locking issue is, and how to avoid it?

For me it souds like a joke if someone talk about locking issues,
since they where under NFS version 2 and are gone since version 3.

I have used version 2 for 8 years but since I use Debian GNU/Linux
to 100% I use version 3 which had never had locking issues while
exporting /home to my Workststions or Maildirs to my Courier-Servers.

Now I migrate to verson 4 because the NFS performance has increased
fantastic...

Thanks, Greetings and nice Day
Michelle Konzack
Systemadministrator
Tamay Dogan Network
Debian GNU/Linux Consultant

--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack Apt. 917 ICQ #328449886
50, rue de Soultz MSM LinuxMichi
0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)

Syndicate content