[dancer-users] Debugging sessions
warren at etr-usa.com
Thu Nov 22 19:54:12 GMT 2018
On Nov 22, 2018, at 1:23 AM, Nikola Mitev <nik at mitev.eu> wrote:
> I am using Starman with Nginx in front of it
That allows parallel access, which means every code path in your app that touches global state needs to be protected against simultaneous modification, else you risk data corruption, which could explain your symptom.
“Global state” means global variables in the Perl app, files on the server, database records, shared memory, etc. Basically, anything that persists beyond the running of each Dancer route handler call.
For such a low usage volume app, I’d recommend switching to a simple single-threaded HTTP server such as HTTP::Server::Simple. HTTP servers that can handle multiple simultaneous connections only help you when you often have multiple users making dynamic requests at the same time. When that happens to a single-threaded HTTP server, the second user just waits for the first to finish their request, so problems like this cannot happen.
That does mean you have a potential scalability problem, but I think too many people think they’re going to be the next Google and therefore need to architect their apps accordingly.
I recommend keeping the Nginx front end, because it lets you offload static content hits to it. Without that, even a single user can hit the Dancer app multiple times in parallel, since then the Dancer app also has to serve all of the static assets, too. With a low-volume web app, each app hit is usually one dynamic pull plus multiple static pulls, so it doesn’t matter that you’re using a single-threaded HTTP server if you’ve got a front-end proxy like Nginx handling all of the static pulls.
More information about the dancer-users