EMA API Performance improvement

Hi,
Please help us to understand how to improve performance with EMA API code to fetch data from TREP server for market updates. We are not getting performance using EMA-API, we have found after our testing that RFA-API has better performance than EMA-API ... can anyone help us to understand what we are missing to tune the performance?

Tagged:

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @dimple.shah

    Thank you for reaching out to us.

    You can check the Real-Time SDKs Performance Test Summary article that summarizes the performance report.

    You can also refer to the EMA PerfTools in the package which demonstrate best practice and coding for performance.

    The key point is that, in the EMA callback methods (such as onUpdateMsg), the application must return as fast as possible. The application can clone retrieved messages and then put them into queues so the messages can be processed by other threads. Therefore, a dispatching thread is freed to dispatch next incoming messages.

    Otherwise, the application can use the horizontal scaling by creating multiple OMM Consumer instances. You can refer to the Horizontal Scaling example in the API package.

  • @Jirapongse

    Thank you for your prompt response.
    We checked the links you have shared and have made some changes in our EmaConfig.xml file but there has not been a significant improvement in performance.
    Right now, we are facing slowness in EMA API while sending subscription requests to TREP server. So, for example, currently with RFA API code in production, we are able to send 30k requests to TREP server but with EMA API this number is only 10k.
    So, I wanted to understand that with EMA API, will subsequent requests be sent to/processed by TREP server only when the response of already sent requests is completely processed at our end?

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @dimple.shah

    According to this discussion, there is no request throttle in EMA. This means that all requests registered by application will directly be sent to server. Moreover, the watchlist size used to generate the performance report is 100,000 items so 30k items should be okay in EMA.

    You may run the EMA PerfTools in the package to verify the number of subcribed items. The PerfTools are uses to generate the performance report.

    Are you using EMA C++, Java, or C#?

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @dimple.shah

    I modified the ex100_MP_Streaming example to subcribe to 30k items from the simulated service and found that it can retrieve all 30k refresh messages.

    {
    OmmConsumer consumer = null;

    try
    {
    AppClient appClient = new AppClient();

    OmmConsumerConfig config = EmaFactory.createOmmConsumerConfig();

    consumer = EmaFactory.createOmmConsumer(config.host("127.0.0.1:14002").username("user"));


    ReqMsg reqMsg = EmaFactory.createReqMsg();
    for(int i=1;i<=30000;i++) {

    consumer.registerClient(reqMsg.serviceName("DIRECT_FEED").name("PTT"+i+".BK"), appClient);
    }


    while(true)
    Thread.sleep(60000);
    }

    You may try modify the simple example to subscribe to 30k items and then check if it can retrieve all responses.

  • Hi @Jirapongse,

    Thanks for your prompt response.
    In the above example, you are connecting to DIRECT_FEED service but in our application we are connecting to ADS services and our service name is IDN_SELECTFEED. Can you please provide an example relevant to that for benchmarking? Also, what is the expected response time for lets say 30k items?

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    DIRECT_FEED is a simulated feed. I need to check that EMA Java can subscribe to 30k items.

    You can run the EMA PerfTools for benchmarking.

    image.png
  • Hi,

    We tried to delegate all the retrieved messages to a thread pool in Java so that all the messages can be read and processed in a separate thread but in this approach we are not able to read the payload in msg object and our getting NullPointerException. Can you please provide an example to clone the retrieved message and process it in a separate thread?

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @dimple.shah

    To clone an update message in EMA Java, you can use the EmaFactory.createUpdateMsg​(UpdateMsg other) method. The cloned messages are put into a queue. Then, another thread gets a clone message from the queue and processes it.

    Sorry, as far as I know, we don't have an example for it.

  • Hi @Jirapongse,

    We tried to clone the RefreshMessage obtained from Refinitiv server by using the method EmaFactory.createRefreshMessage(RefreshMessage refreshMessage) method. But it is taking 8s to create just the clone of RefreshMessage. Please let us know why this is happening, because we cannot use this clone in our application as it processes around 17000 securities from around the world.

    This is the code we use to clone the RefreshMessage:


    public void onRefreshMsg(RefreshMsg refreshMsg, OmmConsumerEvent ommConsumerEvent) {

    long timeInMillisBefore = System.currentTimeMillis();

    RefreshMsg refreshMsgClone = EmaFactory.createRefreshMsg(refreshMsg);

    long timeInMillisAfter = System.currentTimeMillis();

    System.out.println("Time taken to clone: " + (timeInMillisAfter - timeInMillisBefore) + "ms");

    System.out.println("\n");

    }

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    edited March 12

    @dimple.shah

    To improve the performance of EMA applications, there are two key points.

    1. The EMA callback methods must return as fast as possible
    2. The parameters passed to the callback methods can't be used outside the callback methods

    If the application requires only some fields such as, BID and ASK, the application can use view requests to request only the BID and ASK field. The view requests can reduce the size of refresh and update messages and reduce the processing time.

    Instead of using the EmaFactory to clone messages, the application can decode messages to extract required data (BID value and ASK value) and put these values to a queue to be processed outside the callback methods.

    Regarding the performance of the EmaFactory.createRefreshMsg method, I have tested the code with the EMA example. On my machine, it takes milliseconds to clone a message.

    Time taken to clone: 1ms

    It should not take that long (8 seconds) to clone a message. Please contact the support team to investigate this issue.

    If you have a developer connect contact (RDC), you can submit this issue to the API support team via Contact Premium Support. Otherwise, you can submit this issue on GitHub.

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @dimple.shah

    I have updated the response.

    It should not take that long (8 seconds) to clone a message. Please contact the support team to investigate this issue.