Handling large traffic - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Handling large traffic (/showthread.php?tid=26106) |
Handling large traffic - El Forum - 01-06-2010 [eluser]faceh[/eluser] One of my sites is lucky enough to be receiving thousands and thousands of hits and orders a day, which is great! and generally Codeigniter is handling it all really well. However looking at the server logs of slow mysql queries, adding to and cleaning the sessions table seems to be struggling a little. I changed this table to InnoDB hoping the single row locking would help, however this caused multiple issues with: "Deadlock found when trying to get lock; try restarting transaction" - which was a fatal error causing issues, so I've reverted back to MyISAM for now. Does anyone have some tips on handling sessions with very high traffic levels? Thanks. Handling large traffic - El Forum - 01-06-2010 [eluser]n0xie[/eluser] Maybe change the session class to use Key/Value pair storage in memory instead of the database? Handling large traffic - El Forum - 01-06-2010 [eluser]rogierb[/eluser] You can convert the sessions table to a memory table (formerly knows as heap) This is a lot faster then disk tables. There are 2 things to consider: Memory taken by the table, here has to be enought free memory for growth And secondly that the table will be empty after mysql restart. See http://dev.mysql.com/doc/refman/5.1/en/memory-storage-engine.html for more info Handling large traffic - El Forum - 01-06-2010 [eluser]faceh[/eluser] rogierb, thank you for that. Memory was one thing i was considering, will get it set up in a test environment. n0xie, sorry i'm not entirely sure what you mean. The site in question uses the database to store large amounts of userdata which must remain available for the session duration (2 hours) - would this still be possible? In fact, in writing that "stores large amounts of userdata", I wonder if that is where the bottleneck lies, writing serialized data in to a long text field? Handling large traffic - El Forum - 01-06-2010 [eluser]n0xie[/eluser] Basically I'm saying the same as rogierb, but for the future you might want to take a look at memcached Handling large traffic - El Forum - 01-06-2010 [eluser]faceh[/eluser] I see, I will investigate MEMORY database storage then. I actually have memcached and use it in other places, however for sessions where the data inside, even the last activity timestamp, is updated and changes quite regularly, and on top of that the result is unique for every user. I thought it probably wouldn't fit the memcached model as you'd have a memcache record for every sessions record. Handling large traffic - El Forum - 02-14-2010 [eluser]Dirk Einecke[/eluser] Hi, [quote author="rogierb" date="1262807687"]You can convert the sessions table to a memory table (formerly knows as heap)[/quote] But there is a problem: The type of the "user_data" column of the sessions table of codeigniter is a "TEXT" ... and a table with the StorageEngine MEMORY doesn't support TEXT fields. Dirk Handling large traffic - El Forum - 02-14-2010 [eluser]ChiefChirpa[/eluser] [quote author="Dirk Einecke" date="1266177601"]Hi, [quote author="rogierb" date="1262807687"]You can convert the sessions table to a memory table (formerly knows as heap)[/quote] But there is a problem: The type of the "user_data" column of the sessions table of codeigniter is a "TEXT" ... and a table with the StorageEngine MEMORY doesn't support TEXT fields. Dirk[/quote] Which can easily be solved by changing the TEXT column to VARCHAR. Handling large traffic - El Forum - 02-14-2010 [eluser]Dirk Einecke[/eluser] Hi, Quote:Which can easily be solved by changing the TEXT column to VARCHAR. But if you've many data in the session a VARCHAR field is to small. You have to check the length of the fields content before you change it from TEXT to VARCHAR. Dirk Handling large traffic - El Forum - 02-14-2010 [eluser]ChiefChirpa[/eluser] Quote:But if you’ve many data in the session a VARCHAR field is to small. You have to check the length of the fields content before you change it from TEXT to VARCHAR. Which is only really a problem if: 1 - You use an old version of MySQL. 2 - You have some requirement to store far more than normal in the session. For MySQL 5+ the size of VARCHAR is only limited by the maximum row size, which in theory lets you store up to 65,535 bytes, I'd suggest most people's session requirements fit into that very easily. |