Issue Details (XML | Word | Printable)

Key: MDL-11899
Type: Bug Bug
Status: Resolved Resolved
Resolution: Duplicate
Priority: Major Major
Assignee: Dongsheng Cai
Reporter: Eric Merrill
Votes: 0
Watchers: 2
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Chat module performance, possible fix

Created: 24/Oct/07 07:41 PM   Updated: 15/Jun/08 08:31 PM
Return to search
Component/s: Chat
Affects Version/s: 1.5, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.8, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.9
Fix Version/s: 2.0

File Attachments: 1. File chat_performance.diff (19 kB)


Database: Any, MySQL
Participants: Dongsheng Cai, Eloy Lafuente (stronk7) and Eric Merrill
Security Level: None
Resolved date: 15/Jun/08
Affected Branches: MOODLE_15_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE
Fixed Branches: MOODLE_20_STABLE


 Description  « Hide
At our school we have seen performance problems with chat (which of course we know), but we have developed a possible fix.

The general problem that we reduced, is that chat logs (history) is kept in the same table as messages from active conversations. So ever refresh, each client is doing a select on the chat table, which contains all chats. In our case that adds up to +400k rows, so even a simple select takes quite some overhead.

Our solution was to split the chat into 2 table. One is the normal 'chat_messages', and the other is 'chat_messages_current'. Clients query against 'chat_messages_current'. When somebody talks, the message is written to both tables. Every cron cycle, any message older than 8 hours is deleted from 'chat_messages_current'. Basically that means that the frequent select will be against a table that will rarely have more then a few hundred messages in it.

For us, this decreased loads by about a factor of 10 on our MySQL server.

-eric

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Eloy Lafuente (stronk7) added a comment - 12/May/08 09:05 AM
Sounds like a good idea! B-)

Assigning this to Dongsheg to research for Moodle 2.0 (cannot make this for 1.9 because DB aren't recommended in one stable version).

Dongsheng, can you analyse this, at least including:

  • DB changes needed.
  • Changes in normal chat mode.
  • Changes in daemos chat mode.
  • Changes in cron
  • Measure differences under big load.

(not priory for now, fist we must fix other 1.9.x bugs)

Ciao


Dongsheng Cai added a comment - 10/Jun/08 12:11 PM
Attach a patch here.

Dongsheng Cai added a comment - 15/Jun/08 08:31 PM
This solution applied to MDL-14651