PostgreSQL, FreeBSD, SMP and vinum

Today I’ll talk about this very important PostgreSQL server. It was running RedHat Linux 7.x on a dual P3, and a process that sometimes runs there usually took like 17 hours.

There was a spare Dual Xeon laying around, so I decided to replace that old server. Obviously my first choice for a sensitive database server was Debian GNU/Linux, so I installed Debian Sarge to test it: kernel 2.6, PostgreSQL 7.4.6 and scsi drives in software raid-0 (striping) in XFS. Everything was perfect, and the process that took 17 hours in the other box took only 5:30 hours in the new box. A big improvement.

But I am a curious person.

Since there was no hurry to replace that old box (other than the performance since besides the 17 hours process it serves a high-traffic website), I installed FreeBSD 5.3 in that same Dual Xeon.

It was hell.

First, I had some experience with FreeBSD since Aureal System’s server is running it. I have administrator access to the server but I had no experience:
- Installing FreeBSD (this was a piece of cake)
- Making software RAID work (this was HELL)

Now, I have read Michael Lucas’ Absolute BSD and Greg Lehey’s Complete FreeBSD. Lehey’s book has nice chapter about Vinum, FreeBSD’s Raid volume manager (Lehey is vinum’s author after all), but there is a problem with vinum, freebsd5 and SMP (I was installing it in a Dual Xeon remember?). I tried 5.2.1, same problems. Finally it worked with an obscure and undocumented version of vinum called gvinum. The g stands for geom-aware. It worked.

But this was just the beginning.

The beginning of the good news, for me at least. After installing everything and running the previously mentioned process, there was something very hard to believe. In the same box, with the exact same hardware configuration:

Debian+linux 2.6.9 + raid tools + XFS + PostgreSQL 7.4.6 = 5 hours 30 minutes
FreeBSD 5.3 + gvinum + UFS2+S + PostgreSQL 7.4.6 = 44 minutes

Clearly there was something very wrong here.

There wasn’t.

I ran the process again and again and the results were similar. I don’t know exactly if this extraordinary performance gain in this particular process is because of the filesystem or the raid handler, probably it’s because of both. I’ll have to perform some serious benchmarks here, and publish the results of course.

The end of this story is:
- The FreeBSD server is now in production, it runs like a charm and the web pages that access the database now run almost 6 times faster than with the old dual P3.
- I’m installing more FreeBSD boxes.
- I’m reading McKusick’s The Design and Implementation of the FreeBSD Operating System (thanks Breno) and Absolute OpenBSD.
- I am still running debian (unstable) on my desktop boxes, and probably this will not change.

Oh, and I’ll use that SCSI powered dual P3 for my benchmarks, to be published here in a near future.

I just can’t believe I’ve been avoiding BSD so many years.

Comments (14)

  1. Droper wrote::

    WOW!!!!, de 5:30H a 44min es……..bastamte. Definitivamente debo dedicarles unos gigas (y algunas horas) al daemon.

    Friday, February 4, 2005 at 11:03 pm #
  2. Joseph Scott wrote::

    I’ve had good luck with FreeBSD 5.3 using the new geom raid utilities. Take a look at gconcat, gmirror, graid3 and gstripe. It would be interesting to see how this compares in performance with gvinum.

    Friday, February 4, 2005 at 11:47 pm #
  3. ACMhUnTeR wrote::

    No lo olvides tabo solo para simple server x)

    Saturday, February 5, 2005 at 10:12 am #
  4. tabo wrote::

    acmhunter: esto entra en la categoria de servidor con cosas “basicas”. Los programas mas usados tienen ports bien mantenidos. El resto es cuestion de suerte. Como te comente la otra vez, ya me he encontrado con problemas con aplicaciones de servidor en freebsd, aplicaciones que no son “mainstream” como apache, postfix o postgresql. Para este tipo aplicaciones “no basicas” prefiero usar Linux. Y no, no pienso usar el modo de emulacion de linux cuando puedo usar linux :-)

    FreeBSD es bueno para unas cosas y para otras no. No existe nada que sea bueno EN TODO. Para servidores dedicados a aplicaciones “mainstream”, no veo nada de malo en usar freebsd como te dije la otra vez. Si voy a meter mas aplicaciones, voy a la segura y uso linux.

    Los servidores “de verdad” no son para jugar ;-)

    Saturday, February 5, 2005 at 10:20 am #
  5. dave wrote::

    Have you tried profiling both tests to see where the difference is? I’m very curious, now.

    Saturday, February 5, 2005 at 9:33 pm #
  6. BrainX wrote::

    De que forma la comunidad linux va a aprender que BSD es algo totalmente diferente?

    Comparar linux con BSD es como comparar Windows 3.1 con Windows NT… dos cosas completamente diferentes.

    Linux es para los niños… BSD es para los profesionales.

    By the way, siempre he pensado que las maquinas unix solo sirven para ser servidores… Por lo menos asi sera hasta que a alguna persona benevolente y muy freak se le ocurra integrar la parte grafica dentro del kernel, ya que con el X11 se desaprovecha todo el potencial de la maquina.

    Conclusion: Colocar linux en un workstation es un error gravisimo… Colocar BSD en un workstation es peor aun, al menos que puedas vivir sin ningun problema usando un set limitado de aplicaciones.
    Pero… lo que es peor aun es instalar linux en un servidor, ya que es inseguro, inestable y lento… Salvo algunas excepciones donde es indispensable el uso de linux (por ejemplo como Java Application Server y DB2 Server).

    Wednesday, February 23, 2005 at 8:38 pm #
  7. tabo wrote::

    BrainX:

    No conozco tu experiencia o tu trayectoria pero veo en la pagina de tu empresa los logotipos de las distribuciones de Linux Mandrake y Redhat, mas no el de FreeBSD. Eso hace tu empresa una de ninhos y no de profesionales?

    Sobre tu teoria sobre el no uso de Linux/UNIX/*BSD en el desktop, empresas como Oracle, IBM, Novell y otras mas ya estan migrando MILES de estaciones de trabajo a estos entornos. Tu crees que estas empresas migrarian si consideraran que Linux/UNIX/*BSD les ofrecen un “set limitado de aplicaciones” como dices?

    Personalmente tengo bastante tiempo ya trabajando con desktops en Linux (en mi caso Debian), tengo absolutamente todo lo que necesito (y miles de aplicaciones libres mas que ni he visto aun), y puedo interactuar a la perfeccion con el resto de la empresa, tanto a nivel de comunicaciones como de formatos.

    Ya no estamos en 1992 :-)

    Saludos

    Thursday, February 24, 2005 at 9:33 am #
  8. BrainX wrote::

    Buen argumento… el website de mi “empresa” (que es mas un proyecto que una empresa) tiene mucho tiempo sin ser actualizado y no es mi prioridad hacerlo…

    En esos entonces (aprox un año) todavia pensaba que linux era lo “unico” para montar servidores unix…y como ves, cada dia se aprende algo nuevo.

    Con respecto al set de aplicaciones, si hay muchas y buenas aplicaciones open source y propietarias que corren bajo unix, con funcionalidades interesantes y algunas hasta brindan cierta compatibilidad con “guindous”…

    El detalle es que todavia el desempeño de linux me parece muy pobre… y creeme que he probado cada una de las distribuciones principales. Y la costumbre del usuario con “guindous” es bastante ruda… Ademas de la facilidad de instalar y desinstalar programas, es otro punto a favor del producto de microsuave.

    De todas maneras, entre gustos y colores… Yo me quedo con FreeBSD para mis servidores, y Windows para mis desktops.

    :) saluts.

    Thursday, March 3, 2005 at 1:37 pm #
  9. Uzi Suicide wrote::

    Yo uso Linux en desktop hace dos años, y para uso personal no he vuelto a usar Windows, durante todo este tiempo no me he sentido limitado y todo lo que necesite hacer lo hice sin problema alguno, no veo limitaciones mas que en tu cabeza.
    No me concidero un niño por usar Linux en servidores de producción, no creo que todas las empresas que usen Linux sean faltos de profesionalimo, no entiendo en que cabeza se te ocurre hacer comentarios tan pobres.
    Sigue usando Windows que va con tu forma de pensar.

    Uzi Suicide

    Monday, March 7, 2005 at 9:59 am #
  10. Jaxxed wrote::

    it’s funny how much similar a flames war in spanish is to a flame war in english … anyways, outside of the ridiculous linux battle going on in the middle:

    I too am curious as to what the major factors in the difference were. I am a FBSD enthusiast, but I would never have thought to advertise that kind of a difference.
    If it was the RAID/FS combo I would be interested to know.

    Is there a follow up article already

    Saturday, April 30, 2005 at 3:39 pm #
  11. tabo wrote::

    Jaxxed:

    There is no follow up article _yet_, but last week I made a quick test between these 2 boxes:

    1) a modern dual xeon with raid-0 running debian sarge (kernel 2.6.8) and postgresql 7.4.7 (xfs noatime filesystem)
    2) the old dual xeon i mentioned running freebsd 5.3-p10 in an old scsi drive (no striping) and postgresql 7.4.7 (ufs2+s)

    I just loaded both machines with the same DB and then performed a “vaccumdb -faz” lots of times, the old box with freebsd was always faster. I didn’t run any more tests (yet).

    Monday, May 2, 2005 at 9:13 am #
  12. eric wrote::

    I’d be curious to see the difference between these setups using a similar hardware raid.

    Friday, July 7, 2006 at 8:16 pm #
  13. Jason Dixon wrote::

    No offense (I’m a BSD advocate), but I’d like to see some hard numbers to back up your claims. Specifically, the time for vaccumdb on each. Then a profiling of each “process” you’re performing with details on the application architecture.

    Other people need details so they can generate a repeatable comparison.

    Friday, August 24, 2007 at 9:04 am #
  14. Jason Dixon wrote::

    LOL, disregard. I see this post is over 2 years old. :-P

    Friday, August 24, 2007 at 9:06 am #