# Freebsd for a very busy server?



## arya6000 (Nov 25, 2008)

Hi

I currenttly have a busy website on a dedicated server running on Linux, and sometimes the site becomes extremely slow that it gets unusable. Would switching to freebsd make the site load faster at busy times compared to linux?


Thank You


----------



## anomie (Nov 25, 2008)

I'd say: you need to identify the bottleneck first.


----------



## cajunman4life (Nov 25, 2008)

I'd first check the network. Is the network being saturated with requests? 

I'd then try to keep a terminal open to the system with top running, and wait for the busy time to come. If your load average goes much higher than the number of processors you have, you'll need to look at a higher speced server.

Also, is this site dynamic (ie PHP with a MySQL back end) or static HTML files? This will make a huge difference.


----------



## SaveTheRbtz (Nov 25, 2008)

Cache, replicate and shard, my friend. FreeBSD is not a solution, it's a tool. 

PS. And don't forget profiling your code.
PPS. APC Memcahed mysqlproxy


----------



## arya6000 (Nov 25, 2008)

cajunman4life said:
			
		

> I'd first check the network. Is the network being saturated with requests?
> 
> I'd then try to keep a terminal open to the system with top running, and wait for the busy time to come. If your load average goes much higher than the number of processors you have, you'll need to look at a higher speced server.
> 
> Also, is this site dynamic (ie PHP with a MySQL back end) or static HTML files? This will make a huge difference.



I can't find out what is casing the problem, sometimes the load is on 10 and paged load fast and other times the load is about 3 and pages load very slow. Is there any way to find out its network being saturated with requests?


----------



## businessgeeks (Nov 26, 2008)

I've had some experience in configuring freebsd servers as webservers and from what i've different types of websites will require different ways of building the AMP (apache, mysql, php) stack or in some cases LMP (lighttpd, mysql, php) can you describe your webserver stack? and what type of site is it hosting? media sharing (ala youtube)? wiki?


----------



## SirDice (Nov 26, 2008)

arya6000 said:
			
		

> Is there any way to find out its network being saturated with requests?


Ask your hosting provider, they should be able to tell you.


----------



## arya6000 (Nov 26, 2008)

SirDice said:
			
		

> Ask your hosting provider, they should be able to tell you.



When I checked top, I noticed mysql uses 80% of the cpu some times, could that be the cause?


----------



## Mel_Flynn (Nov 26, 2008)

Yep, that's a very good cause, especially with ext3 filesystems.

Look into MySQL's Slow query log.
Chances are one (or more) queries must use temporary tables to form an intermediate result set, for ordering and sorting.
If the result set is large, then this will be written to the tmpdir value in your my.cnf (or /tmp by default). This can cascade into more troubles with ext3 systems, cause it will try to memory journal the writes until out of memory, then flush everything blocking writes in the meantime.
gjournal is a bit smarter.

However, it can also be the number of connections. `mysqladmin processlist' at the time of high usage should give you an idea.


----------



## SirDice (Nov 26, 2008)

arya6000 said:
			
		

> When I checked top, I noticed mysql uses 80% of the cpu some times, could that be the cause?



Oh.. What type of databases do you use and on what type of filesystem? 
MyISAM performs best on regular filesystem (with filesystem cache), while InnoDB performs best on a raw disk (no filesystem cache). 

Search for a script called mytop. It's a top for mysql, quite handy to see what's going on. 
As Mel_Flynn also noted check your slow query log.


----------



## danger@ (Nov 26, 2008)

Sounds like I/O bottleneck...


----------



## mirnshi (Nov 27, 2008)

arya6000 said:
			
		

> When I checked top, I noticed mysql uses 80% of the cpu some times, could that be the cause?


tune your mysql.
1. use mysqldumpslow to summarize the slowest sql.
2. tune the parameters in your my.cnf


----------



## Mel_Flynn (Nov 27, 2008)

mirnshi said:
			
		

> tune your mysql.
> 1. use mysqldumpslow to summarize the slowest sql.
> 2. tune the parameters in your my.cnf



Tune for what? I/O bottleneck is likely, so is bad queries, so is queries that require locking tables, combined with high volume site, cascading into a lot of connections continually having said tables locked.
For the latter, the best "tuning" is adding a second/third MySQL server, setup replication and distributing your reads across the slave server.


----------



## IT_Architect (Jan 2, 2009)

arya6000 said:
			
		

> Hi
> I currenttly have a busy website on a dedicated server running on Linux, and sometimes the site becomes extremely slow that it gets unusable. Would switching to freebsd make the site load faster at busy times compared to linux?  Thank You



You best believe it.  We learned the hard way.  Start with FreeBSD and tweak from there.  When it comes to performance under heavy load Linux is a joke.  We made the switch and will NEVER go back.  It's the learning curve you won't like.  The shortcut is to read the FreeBSD manual.  If anyone can make Linux perform like FreeBSD, please train Real Web Host, Rackspace, and Servstra.  Also, the best tweaker for your server is YOU, not the "experts".  You will get FAR more performance out of the hardware.  It is not possible to tweak a server without it being under a real-world load.  It's the only time you can KNOW the results of your changes and balance CPU to memory etc.  Apache 2.2x will annihilate 1.3x, and if you are using PHP, eAccelerator is the fastest and most stable, not Xcache nor APC, and eAccelerator is the only one that will co-exist with Zend Optimizer and ionCube at the same time, important if you are doing hosting.


----------

