[ejabberd] ejabberd scaling

Alexey Shchepin alexey at sevcom.net
Tue Apr 27 15:38:12 MSD 2004

Hello, Marshall!

On Mon, 26 Apr 2004 17:33:43 -0700, you said:

 MR> hi. can someone give me a pointer to some things that will help
 MR> me understand how to deploy a high volume jabber server using
 MR> ejabberd? let's say i have a server farm with a dozen machines
 MR> and i want them to appear as a single jabber server.

Suppose you already setup ejabberd on one of these machines ('first').
Then do following steps:

1. On another machine ('second') copy ~ejabberd/.erlang.cookie file
from 'first'.

1(alt). You can also add "-cookie big_secret_from_.erlang.cookie"
option to all "erl" commands below.

2. On 'second' run the following command in directory where ejabberd
will work later and under 'ejabberd' user:

erl -sname ejabberd \
    -mnesia extra_db_nodes "['ejabberd at first']" \
    -s mnesia

This will start mnesia serving same DB as ejabberd at first.  You can
check this running "mnesia:info()." command.  You should see a lot of
remote tables and line like the following:

running db nodes   = [ejabberd at first, ejabberd at second]

3. Now run this inside the same "erl" session:

mnesia:change_table_copy_type(schema, node(), disc_copies).

This will create local disc storage for DB.

3(alt). Login with Tkabber on 'first', and choose Discovery -> running
nodes -> ejabberd at second -> DB -> ejabberd:config.  Change 'scheme'
storage type to "RAM and disc copy".

4. Now you can add replicas of various tables to this node with
"mnesia:add_table_copy" or "mnesia:change_table_copy_type" as above
(just replace "schema" with another table name and "disc_copies" can
be replaced with "ram_copies" or "disc_only_copies").

What tables to replicate is very depend on your needs, you can get
some hints from "mnesia:info()." command, by looking at size of tables
and default storage type for each table on 'first'.

Replicating of table makes lookup in this table faster on this node,
but writing will be slower.  And of course if machine with one
replicas is down, other replicas will be used.

Also section "5.3 Table Fragmentation" here[1] can be useful.

4(alt). Same as in 3(alt), but for other tables.

[1] http://erlang.org/doc/r9c/lib/mnesia-4.1.4/doc/html/part_frame.html

5. Run "init:stop()." or just "q()." to exit from erl shell.  This
proably can take some time if mnesia is not yet transfer and process
all data it needed from 'first'.

6. Now run ejabberd on 'second' with almost the same config as in
'first' (you probably don't need to duplicate "acl" and "access"
options -- they will be taken from 'first', and mod_muc and mod_irc
should be enabled only on one machine in cluster).

You can repeat these steps for other machines supposed to serve this

 MR> is this the kind of thing that you sort of get for free with
 MR> erlang?


 MR> thanks!

 MR> /mtr

More information about the ejabberd mailing list