Specify priority for messages/operations?

Options
KevinB
KevinB
edited November 2012 in Photon Server
Hi,

when client sends operations to server, is there a way to specify message priority, so that when server gets a bunch of message in the queue from multiple clients, it can handle operations of higher priority first? Thanks in advance

K

Comments

  • Kaiserludi
    Options
    This is one of the purposes of channels:
    The lower the channel ID, the higher the priority of that channel. So if you have some small amounts of high priority data and other data, that has only low priority, but can happen to appear in huge amounts, then it could be a good idea, to send the high priority data on a channel with a lower channelID. This way it willl still immediately get out, although in channels with higher IDs maybe a lot of data has already been queued for sending, that has not been sent out yet
  • KevinB
    Options
    looks like the default channel id is zero if u don't specify anything in the client code, so all default operations are highest priority? or channel 0 means something else.
  • Kaiserludi
    Options
    Yes, all default channel messages have the highest priority of user messages. Only system messanges on channel -1 have higher priority, but channel -1 is reserved for Photons internal usage.
  • Tobias
    Options
    The channels prioritize messages only per client. So you can't balance between many clients.
    Photon is multi-threaded: Operations affecting the Peer only will be worked on in parallel. Operations that are handled in a Room (anything with a fiber) will be executed serially and in a "first come, first serve" way.
    It makes sense to use channels to separate "conversations" which are independent from each other. Those with lower priority can use higher channels (only available if you set the up before you connect). But using separate channels also means that the sequence is only consistent per conversation (a event sent later in channel 0 might arrive before a event sent in channel 1 a bit later).
  • KevinB
    Options
    Tobias wrote:
    The channels prioritize messages only per client. So you can't balance between many clients.

    just for clarification, when photon server receives messages from client A(using higher priority channel) and client B(lower priority channel) at the same time, there's no guarantee that message form client A will be served first or enqueue to the Room fiber first. is that right?

    K
  • Tobias
    Options
    Right. You can assume that messages from player A and B never arrive at the very same time and are always executed in "random" order in that they arrived.
    Remember: There's a network in between and every single package can be a bit faster or slower than the previous - per connection.
    If you needed order across players, you should try to implement some lock step mechanism, where players more or less take turns.
  • Kaiserludi
    Options
    You have not to worry about some players bombing the server with that many data, that other players stall.
    A typical gameserver in our cloud handles the in game traffic from about 2.000 concurrently online clients. Even if your clients would be non stop sending as fast as they can, it still needs quite a lot of clients, until a server starts to sweat. So a single client, that just sends a lot of data, won't be able to send that much, that other players have to wait for their data to get processed on server side, as the client will get to its limits much faster than the server.
    If your clients send that much, that they overall generate too much traffic for the server to handle, then you are probably either needing to optimize the amount of data to be sent or to just start up more game servers.