What is the Context object and how many do I need?

JamilAhmed
JamilAhmed Member, Employee Posts: 20 Solace Employee

The docs describe a minimum of one context being needed per process. What are the conditions to have more than one?

Tagged:

Best Answer

  • JamilAhmed
    JamilAhmed Member, Employee Posts: 20 Solace Employee
    #2 Answer ✓

    Contexts provide the thread that polls all connected sockets, representing the select() loop and socket processing logic for the API.

    As a general rule, one context per process fits most use-cases. Since even requirements for connecting to multiple brokers are handled with multiple sessions.

    Even in high volume use-cases, typically the network is the bottleneck and adding more contexts won't help. 

    That said, some scenarios where multiple contexts can help: 

    1. Handling very high network activity on a multi-NIC and multi-core server could benefit from parallelism across multiple select loops

    2. If there is heavy processing taking place in the message callback (which is not best practice!), multiple contexts can prevent one session being blocked by the slow receive activity of another.

Answers

  • JamilAhmed
    JamilAhmed Member, Employee Posts: 20 Solace Employee
    #3 Answer ✓

    Contexts provide the thread that polls all connected sockets, representing the select() loop and socket processing logic for the API.

    As a general rule, one context per process fits most use-cases. Since even requirements for connecting to multiple brokers are handled with multiple sessions.

    Even in high volume use-cases, typically the network is the bottleneck and adding more contexts won't help. 

    That said, some scenarios where multiple contexts can help: 

    1. Handling very high network activity on a multi-NIC and multi-core server could benefit from parallelism across multiple select loops

    2. If there is heavy processing taking place in the message callback (which is not best practice!), multiple contexts can prevent one session being blocked by the slow receive activity of another.