Using SQLite as a database backend for a lightweight server
At home I use an rather old (antique some may say) computer (PII@350, 256RAM) as a web server and for testing purposes. All went fine until one of the pages hosted was hit by the "digg effect" and about 15 users wanted to see that page every second. The main problem was that I used MySQL to store some access logs and generate some real-time statistics. Physical memory was limited and Apache and MySQL soon started to fight for every remaining byte and eventually the page was unavailable.
After this experience I started to look for a alternative for the database storage and I found an interesting one: SQLite. SQLite is a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine. Here are some features you may find interesting:
- Transactions are atomic, consistent, isolated, and durable (ACID) even after system crashes and power failures.
- Zero-configuration - no setup or administration needed.
- Implements most of SQL92. (Features not supported)
- A complete database is stored in a single disk file.
- Simple, easy to use API.
- Sources are in the public domain.
SQLite is here a bit faster than MySQL using INNODB and both are a lot slower than MySQL/MYISAM. The main advantage of SQLite and INNODB is that you can use ACID transactions. I found SQLite being a good replacement for MySQL in most of my personal projects but before you start using it you should know the situations where SQLite works well and where it doesn't.
No comments:
Post a Comment