Seeking clarity on websocket processes

49 views
Skip to first unread message

Mike Lowry

unread,
Aug 9, 2016, 1:36:33 PM8/9/16
to openre...@googlegroups.com

In attempting to build an application within the OpenResty environment, I am still a bit fuzzy on the relationship between ports, connections and application processes.  A websocket connection remains open for (possibly) extended period.  Does this mean that a port is occupied or a process thread remains open for the entire time, or is there an event mechanism that will fire up when a new message is received?  I have seen benchmark data indicating over 10,000 concurrent websocket connections.  I have the application code to receive/send messages through the connection and to maintain my own session data in the database, but I’m not sure how to properly structure the overall process.  I’ve read most of what I can find about OpenResty and nginx, but I can’t seem to find a clear explanation.  Can someone help provide some clarity or point me to where I need to study.

 

Thanks,

 

Mike Lowry

Email Mi...@TechCitySouth.com

Phone 678-462-2338

 

Yichun Zhang (agentzh)

unread,
Aug 17, 2016, 5:33:54 PM8/17/16
to openresty-en
Hello!

On Tue, Aug 9, 2016 at 10:35 AM, Mike Lowry wrote:
> In attempting to build an application within the OpenResty environment, I am
> still a bit fuzzy on the relationship between ports, connections and
> application processes. A websocket connection remains open for (possibly)
> extended period. Does this mean that a port is occupied or a process thread
> remains open for the entire time, or is there an event mechanism that will
> fire up when a new message is received?

OpenResty uses I/O multiplexing so it's just socket overhead and port
occupation. No OS threads nor OS processes are blocked on such slow or
idle connections. When a new message is received, it will trigger a
read event returned by the epoll_wait() syscall (or something similar,
depending on your OS and configurations), which sits at the core of
the nginx event loop.

Regards,
-agentzh
Reply all
Reply to author
Forward
0 new messages