Popular stories:

Nginx proxy_read_timeout catch or double php script execution

I was working on import script recently. Expected execution time was more than 60 seconds, the default value of proxy_read_timeout directive in Nginx that’s why Nginx displayed nice 504 Gateway Timeout error every time I run the script, even though the script was still running on the back end.

I didn’t pay attention until I noticed that my import script gets executed multiple times even though I executed it just once (by going to script url in the browser).. That problem was driving me nuts because I was trying to figure what triggers second script execution. After countless hours spent on debugging I finally figured that the problem was caused by Nginx proxy_read_timeout directive..

It turned out that after read_timeout interval passed, Nginx would call that script one more time trying to get the response, so for me it meant that two jobs were executing in parallel updating same resource (database in my case) at the same time, causing unexpected behaviour..

To demonstrate the problem I wrote super simple php script:

and in this case your proxy_read_timeout should be less that 10 seconds. In the error log you will see 2 entries instead of one.

For most scripts that behaviour is not a problem, but make sure you increase Nginx read_timeout for critical scripts which are taking some time (more than default 60 seconds) to execute..

I helped to build and maintain the infrastructure for Game of Thrones, the biggest and most popular show in the world.

Do you want to know the single most important thing that I learned over the years?

NONE OF IT REALLY MATTERED…

Yes, it was fun for a while.

Yes, like most of us engineers I was making good money.

But at the end of the day, I would still have to show up at work and sell my time.

Sometimes I would come in, sit in my cubicle and dream about things I could do instead of staring at the screen all day long…

I could go to the beach with my wife and my son.

I could fly to El Classico game in Barcelona with my brother and watch Messi scoring amazing goals.

I could organize a surfing trip to South Africa and other awesome places around the world. Places I’ve never seen.

I could work on my own projects that would make the impact in the world or at the very least, make me some money.

Hell, I could just sit home and do absolutely nothing!

And yet there I was still in my cubicle 12 years later with big hopes and dreams and pretty much nothing to show for…

Sounds familiar?

The tipping point for me was when I started buying games on Steam and GoG and playing them in my mind.

Nothing to install, no need to upgrade video cards, no need to feel bad in front of my wife, no time to waste…

You are right, I was spiraling down and needed a break, but more so I felt like I needed some radical changes in my life.

I’m sure you heard this saying before: “Insanity: doing the same thing over and over again and expecting different results”

It became clear that the road I was walking on would lead me to mediocre life.

The problem was that I didn’t want to be mediocre. I wanted my life to be awesome, full of fun, happiness and excitement!

I wanted to make a difference in the world, leave a legacy, make my kids proud, live without regrets, discover my true purpose.

So about a year ago, I set out on my new journey…

I left my old comfortable job, attended multiple high profile non-technical events (including Tony Robbins UPW), joined an expensive business program, hired a personal coach and mentor, met a bunch of people who were able to disconnect from the Matrix and never looked back.

And let me tell you – there is another world out there, something we technical guys don’t get to experience!

There is hope.

Now, here is my question for you:

Do you want to continue to be just a tool in someone else’s hands or you want to upgrade yourself and become a Rain Maker?

If you want to find out who you really are, take full control of your life, step outside your comfort zone in order to grow physically, mentally and financially and help others along the way, then the Red pill is for you. Just drop your email in the field below and we’ll be in touch.

Take a Blue pill and you will forget that we ever met. You will close this popup and continue reading articles about Nginx, Kubernetes, Docker, secretly dreaming of life that you could have… (or pathetically thinking that you will have it one day just by perfecting technical skills)