Improve performance of file-based-database web calendar app
May 23, 2006 12:01 PM
Subscribe
I am in charge of
a custom installation of a
web calendar application (ORS) that is feeling the strain of too many users and the consequences of some unusual policies. I need some advice on how to get better performance out of this application.
I installed ORS about 3 years ago. Some quick facts about ORS: it is written in PHP, and uses CSV files to store all its data - no mysql, no berkeley dbs, just straight CSV files. All the CSV reading/writing routines are handwritten - the author makes no use of php's libraries. Same for the file locking routines - the author uses his own file locking routines, creating, reading, and deleting his own lockfiles.
I customized ORS heavily in a number of ways for our location, the most important being an institution of a weekly time release. In a normal ORS install, blocks of time become available on a rolling basis - at every moment, a block of time some x number of weeks in the future is becoming available. Administrators here felt this was unfair to people who didn't have the freedom (or assistants) to hover over a keyboard at the precise time x weeks before the appointment time they needed. So, instead, every Tuesday at 9:30 AM, an entire week's worth of time 3 weeks in the future all of a sudden becomes available.
Result: every Tuesday at 9:30 AM, a hundred people simultaneously start hammering the server, which immediately stops responding to anyone at all.
What can I do?
The program is currently on a shared machine with the rest of the department's pages. I've vaguely heard mention of things like lighttpd as a possible solution, but I'd love some specific details.
posted by dmd to computers & internet (12 comments total)
1) Make the application fast enough to handle the people. In this case, it means using a real database, and rewriting every part of the program to forget about csv files and instead use MySQL or some other database.
2) Make the people slow enough for the application to handle. This is a little difficult, because ideally you'd like one person to be able to sign on, access a number of pages, then sign off, sequentially, without letting too many others compete. You could, for example, only have Apache spawn a max of 2 or 3 child processes. So even if five hundred people try to use it at the same time, most of them will get connection timeout errors rather than actual pages, and the application itself won't be overloaded. It will still be hard for users to complete their scheduling. You could run a reverse proxy to rate-limit the requests... it'll still be a little hard. If your app can handle two users/minute and you have a hundred users competing to use it, nothing is going to make that wait magically go away.
3) Change the department policies. No doubt the developer of ORS put in the rolling access times for exactly this reason - he knew his app couldn't handle vast numbers of simultaneous accesses, it wasn't designed to. So you've undone something the developer did for exactly this reason, and now you're encountering exactly the problem that he solved. At the *least* you could open a day's worth of scheduling every day, rather than a week's worth once a week.
4) Pick a new calendar app. There are many. Ones designed to use a real database should handle many more simultaneous accesses.
posted by jellicle at 12:22 PM on May 23, 2006