Scaling
Had a bit of a nightmare the last couple of days! When we moved the MSG Block over to the ‘live’ server, we started to find that things weren’t working very well – the Moodle site was incredibly slow, this obviously(!) turned out to be a problem with the MSG block slowing things down with the number of requests being made keeping peoples presence status up to date. And this was with relatively few users…
So I’ve had to make fairly big changes over the last day or so to the MSG block to reduce the amount of communication between the Moodle and MSG servers. The way I’ve got around this is to create a database table for the MSG block to cache users presence for a minute or so and only to update the presence when the cache has expired. The obvious downside of this is that user’s presence doesn’t appear quite so ‘live’ on the browser page. There’s also a kind of natural limit to how long the cache should be set to – as if it’s too long it defeats the point of having the live updates via AJAX and the presences only refreshed when the whole page is refreshed (and no AJAX). At the moment I have the cache set to 1 minute, which seems ok for now, but we may have to make this even longer if performance drops again.
I would have preferred to have kept this cache in memory rather than database table (which keeps needing to be read and updated), but apparently this is a bit tricky to do in PHP – see the posting I made on the Moodle forums at: http://moodle.org/mod/forum/discuss.php?d=54994










