Scalability of TheBroth

March 15th, 2006 in The Making of TheBroth · By Nicole Stiles

In creating TheBroth, we wanted to ensure that the application would scale smoothly to accommodate both a high volume of players and a constantly fluctuating number of players. The solution had to balance the number of players interacting in each room: too many and play areas would become somewhat chaotic with tiles constantly moving; too few and play would become boring.

The solution chosen involves grouping players in each room into sets and manipulating TheBroth’s database to spawn new sets and collapse empty sets. An overview of the concepts involved in implementing this solution is provided below.

Rooms, sets and players

Rooms

In terms of TheBroth, a room is a reserved space which contains at least one mosaic game area where players can interact. Each room is designated by a unique URL (eg. thebroth.com/my_room).

TheBroth offers a ‘public’ room located at http://www.thebroth.com/mosaic. First-time players who visit TheBroth homepage (http://www.thebroth.com) and click ‘Enter mosaic’ are automatically directed to the public room. Account holders can elect to have their room display either this shared mosaic or a room-specific mosaic.

Registered users can personalize their room to display a banner, backlink and up to four URLs. Account holders can sign up for as many rooms as they wish, and are free to invite whoever they wish to play in their room by sending them the room’s URL.

Repeat visitors who visit the TheBroth homepage will be directed to the room that they had been in before. If a player had been playing in http://www.thebroth.com/janedoe before, then the “Enter mosaic” link will always direct them back to the “janedoe” room. This feature is important for room owners and marketers who want to avoid that “their” visitors are lost to another mosaic (such as the public one in /mosaic or any other room).

Shared mosaics

By default, account holders’ rooms display the shared mosaic at http://www.thebroth.com/mosaic. Players in a room which uses the shared mosaic are able to interact with players from the public room and from other rooms displaying the shared mosaic.

Displaying the shared mosaic is useful for increasing the apparent activity level and number of players in a room: a room which has only a few players appears more lively when combined with activity from the shared mosaic.

Room-specific mosaics

Account holders can elect to have their room display a room-specific mosaic. Players interacting in such a room can only interact with other players in the same room, and do not see activity or players from the public mosaic.

All rooms must contain at least one set, and can contain several if there are many players interacting at once.

Sets

A set is a group of players that share the same mosaic game area. Each set can contain a maximum number of players, and this maximum is the same across all sets.

Each new player entering one of TheBroth’s rooms is automatically assigned to the first set which is not yet at maximum capacity. Players in different sets interact on different mosaic game areas.

In the case of a shared mosaic, players may be assigned to a set containing players from the same room and players from the public room, and thus interact on the same mosaic game area despite being in different rooms. In the case of a separate mosaic, however, players are only assigned to sets with other players in the same room.

Once assigned to a set, players interact only with the other members of their set. TheBroth’s players are unaware that they are grouped into sets, and therefore cannot choose which set they are allocated to.

Players

Active players

Active players are players who have moved a tile or rated another player in the last 60 seconds. A set’s total number of players is determined by looking at the number of active players it contains.

Inactive players

Inactive players are players who have not moved a tile or rated another player in the last 60 seconds. These players are similar to spectators, as they still see other player’s moves in the mosaic game area although they are not participating. Inactive players are not counted in determining a set’s total number of players.

‘Asleep’ players

Players who have not moved a tile or rated another player for 30 minutes are deemed to be asleep. These players no longer see other player’s moves in the mosaic game area, and are not counted in determining a set’s total number of players.

Expired players

Players who have not moved a tile or rated another player for 35 minutes are considered expired. Once a player expires, he is deleted from the room, and deleted from the TheBroth altogether, unless registered.

Set spawning

Once the number of active players in a set exceeds the set’s maximum capacity, a new set is spawned to balance the number of active players in each mosaic game area.

Spawning a new set involves the following steps:

  1. The data from the current mosaic game area are duplicated.
  2. Half of the active players are transferred to a new set, while the other half remain in the existing set.
  3. A new mosaic game area is created with tiles in the same positions as the original mosaic game area.
  4. Players in the newly created set are seamlessly transferred to the new mosaic game area, and those in the existing set continue playing on the original mosaic game area.

Set collapsing

Once all players in a set are either inactive, asleep or expired, the set’s data are deleted from the database and its mosaic game area ceases to exist.

How it works

To maintain an optimum number of sets per room, the system checks each room every 5 seconds to determine:

  1. Whether any sets contain more than the maximum number of active players; and
  2. Whether any sets now contain zero active (or rather, non-expired) players.

New sets are spawned in rooms containing sets with more than the maximum number of active players, and sets with zero active players are collapsed. Expired players detected are also deleted from the system as part of this process.

Share this:
  • del.icio.us
  • StumbleUpon
  • Furl
  • Netscape
  • Reddit
  • Technorati
  • YahooMyWeb

Leave a comment