Skip to content

Freeswitch: Lua performance bottleneck after importing http.request #201

Open

Description

@Ajinkya009

We use Freeswitch stack with 4000 channels to send IVR calls. The logic is written in Lua. We need to send a POST request whenever a call gets picked up. For this purpose we are using lua-http package. Both the functionalities, i.e. outbound calling and sending POST request are implemented in same Lua file. When we import lua-http package (require "http.request"), we observe high CPU utilization (more than 95%). This also affects outbound calls. We have also observed that, whenever number of threads importing the library cross 1500, system starts slowing down. One possible solution is to restrict number of threads but that would reduce number of outbound calls. Is there anything else we can do to remove this bottleneck?

System configuration:
Operating system: Debian,
4 core CPU, 16G RAM

Activity

  1. daurnimator commented on Jun 17, 2022

    @daurnimator
    Owner

    That's really odd....
    Do you have a way for me to replicate? preferably outside of the context of freeswitch?

  2. Ajinkya009 commented on Jun 17, 2022

    @Ajinkya009
    Author

    @daurnimator Thank you for responding. I've attached two scripts which will help you in reproducing the issue.
    lua_script:
    local request = require "http.request"

    Bash:
    #!/bin/sh
    set -m # Enable Job Control
    for i in seq 3000; do # start 3000 jobs in parallel
    lua5.3 ~/Documents/scripts/lua_script.lua &
    done

  3. daurnimator commented on Jun 17, 2022

    @daurnimator
    Owner

    That script doesn't fail for me.

  4. Ajinkya009 commented on Jun 17, 2022

    @Ajinkya009
    Author

    @daurnimator Could you please check CPU utilization. I've attached a screenshot of CPU utilization on my machine. Please note we observed this with just 200 threads.
    200_threads_with_http_request
    .

  5. Ajinkya009 commented on Jun 30, 2022

    @Ajinkya009
    Author

    @daurnimator Did you check this further?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions