August 19, 2008, at 09:51 AM

20080819

I know I said it would be my last narcissistic stunt but ...

Right, it seems the subject on COlivri was shown for the third time on TV yesterday at lunch time, this time nationwide ... as per usual the server collapsed under the load but no data were lost :P

Scaling a web site for TV is hard! My tiny server dealt with being on the front page of Wired with IEforge which I was pretty thrilled about. TV is another ball game. A report of 1m40s generates a frightening number of visits in a very short amount of time.

Most of the errors were caused by the database being locked. I know SQLite is not designed for high load web sites but it is super convenient in the development phase and it manages to power COlivri very well most of the time ;) I have decided to migrate to PostgreSQL because ... why not :P

It's not done yet but WE have done it on a test server. It would have been a nightmare doing that without Raphael's help!

Django failed to be helpful in the migration. Didn't feel like figuring out why henceforth we opted for the SQLite .dump method on the export side and psql -f command.sql on the import (building the schema with Django ./manage.py syncdb BUT ...

SQLite exports boolean as 0/1 which PostgreSQL doesn't understand unless they are explicitly casted. We modified the exported SQL to change all the boolean 0 and 1 to false and true for the import to work.

Then everything seems to work but doesn't! PostgreSQL deals with auto-increment id fields with sequences that need to be set for each imported table using:

SELECT SETVAL(max(id), sequence_for_table) FROM TABLE;

I'll do some more testing to make sure everything is working and then automate the process so the server downtime is minimal during the switch ;)

blog comments powered by Disqus