[erlang-questions] How to manage C ports that are suppose to handle a very high number of requests

Arshad Ansari <>
Thu Aug 25 15:01:03 CEST 2016


Hello there,

I had earlier asked about how to access LuaJIT from erlang [
http://erlang.org/pipermail/erlang-questions/2016-August/089939.html
<http://erlang.org/pipermail/erlang-questions/2016-August/089939.html\>]
and based on the responses, I decided to go with C port. It was working all
great. Except, when I tried to call the same C-Port [luajit] code from
erlang-diameter server. Since the requests were high, but not very high
(approx 10K per second), the code fails with stack overflow on c side.

Now I thought, I would create a seperate C port for each requests but that
would mean there will be around 10K c-port processes. I'm now wondering how
to handle this size of requests from the c port. Any help or direction is
appreciated. Please let me know if my question is not clear. I'm attaching
the code to access lua that works with single instance of c-port process.

Regards
Arshad

/************ CODE Details *********************/

erl_com.c contains code to send/receive data from c side
port.c runs the lua code and has main
script.lua
relay.erl starts the relay server and c port to talk to lua
relay_cb.erl handles requests and communicates with lua
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160825/42d30da6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: script.lua
Type: text/x-lua
Size: 147 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160825/42d30da6/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: relay.erl
Type: text/x-erlang
Size: 3587 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160825/42d30da6/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: relay_cb.erl
Type: text/x-erlang
Size: 3436 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160825/42d30da6/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: node.erl
Type: text/x-erlang
Size: 5422 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160825/42d30da6/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: port.c
Type: text/x-csrc
Size: 999 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160825/42d30da6/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: erl_comm.c
Type: text/x-csrc
Size: 743 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160825/42d30da6/attachment-0005.bin>


More information about the erlang-questions mailing list