Archive for the ‘linux’ tag
Recently, I was using a laptop with Ubuntu installed. Anticipating that I might not have Wi-fi and needed to tether my Windows Mobile phone for Internet, I installed SynCE. I was in a rush and didn’t have time to really test it other than loading Google (isn’t that the “standard” test for Internet connectivity now? ) As it turned out, the place I went to did have Wi-fi access, but I hadn’t installed the Wi-fi drivers for the laptop. To install the Wi-fi drivers, I would need to tether my phone.
Unfortunately I was facing a very strange situation. When I tethered my phone, the laptop did have Internet. But I couldn’t load anything other than the Google home page. I could ping, and I could do nslookup. I could wget the Google homepage consistently. But I couldn’t search or load any other pages. apt-get refused to work as well. I tried to FTP, and discovered that the connection would choke if I tried to do a directory listing of a large directory.
I’m now happily tethering my Windows Mobile 6.1 phone with Ubuntu 9.10, using just SynCE + MTU 1000.
I’ve seen the painful lessons many times: lazy website owners thinking their webhost would last forever, and neglecting to save their own backups. But really, you learn a lesson the best when you actually feel the pain. And I sure did.
To prevent this, I decided to automatically, and regularly backup my VPS and store them on my computer. I searched Google a bit, and found two typical approaches: a simple shell script, or a full-fledged backup solution. I decided that I didn’t need something like Amanda or Bacula. I didn’t feel too inclined to messing with scripts though. However, I found this nifty tutorial to backup web server files and MySQL databases. The tutorial came complete with a script generator, which was really handy.
I made some changes to the generated script though:
- I prefer the yyyy-mm-dd date format for easier (and natural) file name sorting. I also changed the timestamp of the MySQL dumps to match the file dump timestamp format.
- Because I’m not running large websites, I decided to change the script so that the full backup is only run once a month instead of once a week, to save on resources.
With this script running, I should not have to encounter another situation where I lose months of data. Well, unless the backups stop running without me realising.
I chose to use the LiteSpeed Web Server over Apache HTTP Server because of the low memory footprint, as well as better performance for PHP. The GUI admin interface is also a big plus point, making it easy to administer the server.
As I was adding sites and working to bring them online, I realised that my sites were loading very slowly. I installed WP Tuner, a WordPress plugin, to try and see if the bottleneck was on LiteSpeed or MySQL. From the statistics, the delay occurred at the very first “Start” marker, taking 30 seconds, or even as long as 60 seconds. This wasn’t a problem with MySQL then. Next, I used top to monitor CPU and memory usage. It turns out that each PHP process took up 20MB of memory. With a VPS of only 128MB memory, and each site load using multiple processes, this was a huge problem. I was quickly running out of memory, and there was a lot of swapping. A quick search on Google, and I found this page of documentation, which states:
There are two ways to let PHP handle multiple requests concurrently, Server Managed Mode and Self Managed Mode. In Server Managed Mode, LiteSpeed web server dynamically spawn/stop PHP processes, in this mode “Instances” should match “Max Connections” configuration for PHP external application. To start PHP in Self Managed Mode, “Instances” should be set to “1″, while “LSAPI_CHILDREN” environment variable should be set to match the value of “Max Connections” and >1. Web Server will start one PHP process, this process will start/stop children PHP processes dynamically based on on demand. If “LSAPI_CHILDREN” <=1, PHP will be started in server managed mode.
Self Managed Mode is preferred because all PHP processes can share one shared memory block for the opcode cache.
Some months back, I was on the lookout for a cheap NAS (network attached storage). The idea was that it would be cheaper than buying a second system, and if I used a NAS instead of just adding a hard disk to my PC, I should be able to switch off my PC sometimes, and not worry about shared files being inaccessible. Plus, I just wanted to play with a new gadget.
I had two choices at that time: Planex NAS-01G or Kuro-Box (a.k.a. Kurobox, KuroBox, Kuro Box…). The Kuro-Box was about SGD40 more expensive, but it was essentially a Linux box, and highly “hackable”. The Planex NAS-01G is also a Linux box, but it is meant to work out-of-the-box, and has limited “hack-ability”.