NGINX / PHP-FPM: Ajax slow first request, good next onesPHP-FPM with nginx load balancing long request blocks...

For Loop and Sum

Find the number of ways to express 1050 as sum of consecutive integers

Why is my solution for the partial pressures of two different gases incorrect?

Using AWS Fargate as web server

Could be quantum mechanics necessary to analyze some biology scenarios?

How to acknowledge an embarrassing job interview, now that I work directly with the interviewer?

What does a violin mute do?

Can the Count of Monte Cristo's calculation of poison dosage be explained?

Does Windows 10's telemetry include sending *.doc files if Word crashed?

What is the meaning of "pick up" in this sentence?

Proof by Induction - New to proofs

Is the theory of the category of topological spaces computable?

Predict mars robot position

What is Crew Dragon approaching in this picture?

How to avoid being sexist when trying to employ someone to function in a very sexist environment?

Why is working on the same position for more than 15 years not a red flag?

ip vs ifconfig commands pros and cons

Incompressible fluid definition

How to add multiple differently colored borders around a node?

If I delete my router's history can my ISP still provide it to my parents?

Do any poskim exempt 13-20-year-olds from Mussaf?

Dilemma of explaining to interviewer that he is the reason for declining second interview

Sometimes a banana is just a banana

How to prepare vegetables for a sandwich that can last for several days in a fridge?



NGINX / PHP-FPM: Ajax slow first request, good next ones


PHP-FPM with nginx load balancing long request blocks all other requestsPHP-FPM process timeouts but NGINX does not close the session with ClientSuggest me a good php-fpm configuartionLatency, Nginx & PHP-FPMnginx & php-fpm very slow on first accessNginx PHP-FPM stops after connection timeoutWhat's the Relationship Between an nginx worker_process and PHP-FPMNGINX error when using external PHP-FPMNGinX + PHP-FPM Microservices deadlockNginx and PHP-FPM concurrent requests from same IP













2
















  • The CMS is Elxis, which comes from a variant of Joomla (PHP).

  • The server is running nGinx with PHP-FPM

  • All requests get logged and executed, eventually, B U T!!!


When firing a specific request via the URL bar, the request gets executed immediately. However, when fired via ajax (through jQuery), the same request has a very strange behaviour.



Namely: First request (on a media manager), to view picture details, is to be fired with Ajax. It is logged on the browser, but not on the server... Not just yet... After some good 40-50 seconds, the request appears on the server and then it is responded immediately.



All following requests are executed immediately, no problem. Only the first one is rough..



I am in trouble because there is not any error logged anywhere: Everything seems sane, except for the lag of the first request to reach the server...



It is not routing (the site is already up and requests have been served), it is not resolution (the ip is in my /etc/hosts file).



And to add a little cherry on top of the cake, trying to capture packets (tcpdump) on the server produces no output: The request is not here yet...
Tried on client too: no output - for at least 40 secs...



It's all on the browser, developer console shows no error, just a pending request.



Does any of this ring a bell to anyone?



The server:
nginx version: nginx/1.6.2
PHP 5.6.7-1 (cli)
PHP 5.6.7-1 (fpm-fcgi)


jQuery version 1.11

The client: tried on Firefox 39 (ubuntu) and Chromium 41



Note: I've asked the same question on stackoverflow, as I can't clearly figure if it's code or architecture to blame...










share|improve this question














bumped to the homepage by Community 13 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Duplicate posted on Stack Overflow: NGINX / PHP-FPM: Ajax slow first request, good next ones

    – Paul
    Apr 10 '15 at 20:57






  • 1





    @Paul, yes, read my footnote, please...

    – Stavros Souvatzis
    Apr 11 '15 at 7:31











  • Hey, any news ?

    – Etienne Gautier
    Jul 10 '17 at 8:59











  • No, no news. I do not run the project anymore. Somehow though, I think it's stopped happening.

    – Stavros Souvatzis
    Jul 10 '17 at 12:33
















2
















  • The CMS is Elxis, which comes from a variant of Joomla (PHP).

  • The server is running nGinx with PHP-FPM

  • All requests get logged and executed, eventually, B U T!!!


When firing a specific request via the URL bar, the request gets executed immediately. However, when fired via ajax (through jQuery), the same request has a very strange behaviour.



Namely: First request (on a media manager), to view picture details, is to be fired with Ajax. It is logged on the browser, but not on the server... Not just yet... After some good 40-50 seconds, the request appears on the server and then it is responded immediately.



All following requests are executed immediately, no problem. Only the first one is rough..



I am in trouble because there is not any error logged anywhere: Everything seems sane, except for the lag of the first request to reach the server...



It is not routing (the site is already up and requests have been served), it is not resolution (the ip is in my /etc/hosts file).



And to add a little cherry on top of the cake, trying to capture packets (tcpdump) on the server produces no output: The request is not here yet...
Tried on client too: no output - for at least 40 secs...



It's all on the browser, developer console shows no error, just a pending request.



Does any of this ring a bell to anyone?



The server:
nginx version: nginx/1.6.2
PHP 5.6.7-1 (cli)
PHP 5.6.7-1 (fpm-fcgi)


jQuery version 1.11

The client: tried on Firefox 39 (ubuntu) and Chromium 41



Note: I've asked the same question on stackoverflow, as I can't clearly figure if it's code or architecture to blame...










share|improve this question














bumped to the homepage by Community 13 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Duplicate posted on Stack Overflow: NGINX / PHP-FPM: Ajax slow first request, good next ones

    – Paul
    Apr 10 '15 at 20:57






  • 1





    @Paul, yes, read my footnote, please...

    – Stavros Souvatzis
    Apr 11 '15 at 7:31











  • Hey, any news ?

    – Etienne Gautier
    Jul 10 '17 at 8:59











  • No, no news. I do not run the project anymore. Somehow though, I think it's stopped happening.

    – Stavros Souvatzis
    Jul 10 '17 at 12:33














2












2








2









  • The CMS is Elxis, which comes from a variant of Joomla (PHP).

  • The server is running nGinx with PHP-FPM

  • All requests get logged and executed, eventually, B U T!!!


When firing a specific request via the URL bar, the request gets executed immediately. However, when fired via ajax (through jQuery), the same request has a very strange behaviour.



Namely: First request (on a media manager), to view picture details, is to be fired with Ajax. It is logged on the browser, but not on the server... Not just yet... After some good 40-50 seconds, the request appears on the server and then it is responded immediately.



All following requests are executed immediately, no problem. Only the first one is rough..



I am in trouble because there is not any error logged anywhere: Everything seems sane, except for the lag of the first request to reach the server...



It is not routing (the site is already up and requests have been served), it is not resolution (the ip is in my /etc/hosts file).



And to add a little cherry on top of the cake, trying to capture packets (tcpdump) on the server produces no output: The request is not here yet...
Tried on client too: no output - for at least 40 secs...



It's all on the browser, developer console shows no error, just a pending request.



Does any of this ring a bell to anyone?



The server:
nginx version: nginx/1.6.2
PHP 5.6.7-1 (cli)
PHP 5.6.7-1 (fpm-fcgi)


jQuery version 1.11

The client: tried on Firefox 39 (ubuntu) and Chromium 41



Note: I've asked the same question on stackoverflow, as I can't clearly figure if it's code or architecture to blame...










share|improve this question















  • The CMS is Elxis, which comes from a variant of Joomla (PHP).

  • The server is running nGinx with PHP-FPM

  • All requests get logged and executed, eventually, B U T!!!


When firing a specific request via the URL bar, the request gets executed immediately. However, when fired via ajax (through jQuery), the same request has a very strange behaviour.



Namely: First request (on a media manager), to view picture details, is to be fired with Ajax. It is logged on the browser, but not on the server... Not just yet... After some good 40-50 seconds, the request appears on the server and then it is responded immediately.



All following requests are executed immediately, no problem. Only the first one is rough..



I am in trouble because there is not any error logged anywhere: Everything seems sane, except for the lag of the first request to reach the server...



It is not routing (the site is already up and requests have been served), it is not resolution (the ip is in my /etc/hosts file).



And to add a little cherry on top of the cake, trying to capture packets (tcpdump) on the server produces no output: The request is not here yet...
Tried on client too: no output - for at least 40 secs...



It's all on the browser, developer console shows no error, just a pending request.



Does any of this ring a bell to anyone?



The server:
nginx version: nginx/1.6.2
PHP 5.6.7-1 (cli)
PHP 5.6.7-1 (fpm-fcgi)


jQuery version 1.11

The client: tried on Firefox 39 (ubuntu) and Chromium 41



Note: I've asked the same question on stackoverflow, as I can't clearly figure if it's code or architecture to blame...







nginx php-fpm ajax






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 10 '15 at 15:39









Stavros SouvatzisStavros Souvatzis

1185




1185





bumped to the homepage by Community 13 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 13 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Duplicate posted on Stack Overflow: NGINX / PHP-FPM: Ajax slow first request, good next ones

    – Paul
    Apr 10 '15 at 20:57






  • 1





    @Paul, yes, read my footnote, please...

    – Stavros Souvatzis
    Apr 11 '15 at 7:31











  • Hey, any news ?

    – Etienne Gautier
    Jul 10 '17 at 8:59











  • No, no news. I do not run the project anymore. Somehow though, I think it's stopped happening.

    – Stavros Souvatzis
    Jul 10 '17 at 12:33



















  • Duplicate posted on Stack Overflow: NGINX / PHP-FPM: Ajax slow first request, good next ones

    – Paul
    Apr 10 '15 at 20:57






  • 1





    @Paul, yes, read my footnote, please...

    – Stavros Souvatzis
    Apr 11 '15 at 7:31











  • Hey, any news ?

    – Etienne Gautier
    Jul 10 '17 at 8:59











  • No, no news. I do not run the project anymore. Somehow though, I think it's stopped happening.

    – Stavros Souvatzis
    Jul 10 '17 at 12:33

















Duplicate posted on Stack Overflow: NGINX / PHP-FPM: Ajax slow first request, good next ones

– Paul
Apr 10 '15 at 20:57





Duplicate posted on Stack Overflow: NGINX / PHP-FPM: Ajax slow first request, good next ones

– Paul
Apr 10 '15 at 20:57




1




1





@Paul, yes, read my footnote, please...

– Stavros Souvatzis
Apr 11 '15 at 7:31





@Paul, yes, read my footnote, please...

– Stavros Souvatzis
Apr 11 '15 at 7:31













Hey, any news ?

– Etienne Gautier
Jul 10 '17 at 8:59





Hey, any news ?

– Etienne Gautier
Jul 10 '17 at 8:59













No, no news. I do not run the project anymore. Somehow though, I think it's stopped happening.

– Stavros Souvatzis
Jul 10 '17 at 12:33





No, no news. I do not run the project anymore. Somehow though, I think it's stopped happening.

– Stavros Souvatzis
Jul 10 '17 at 12:33










1 Answer
1






active

oldest

votes


















0














I faced similar kind of problem and i ended up increasing number of php-fpm workers. I used the following settings in www.conf (pool.d) to solve the problem i was facing. I had an analytics server setup which was tracking pageviews and there was a delay of 15-20s in API recording the pageviews. Tuning the following settings solved my problem, maybe it might help you.



pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3





share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "2"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f681861%2fnginx-php-fpm-ajax-slow-first-request-good-next-ones%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I faced similar kind of problem and i ended up increasing number of php-fpm workers. I used the following settings in www.conf (pool.d) to solve the problem i was facing. I had an analytics server setup which was tracking pageviews and there was a delay of 15-20s in API recording the pageviews. Tuning the following settings solved my problem, maybe it might help you.



    pm = dynamic
    pm.max_children = 5
    pm.start_servers = 2
    pm.min_spare_servers = 1
    pm.max_spare_servers = 3





    share|improve this answer




























      0














      I faced similar kind of problem and i ended up increasing number of php-fpm workers. I used the following settings in www.conf (pool.d) to solve the problem i was facing. I had an analytics server setup which was tracking pageviews and there was a delay of 15-20s in API recording the pageviews. Tuning the following settings solved my problem, maybe it might help you.



      pm = dynamic
      pm.max_children = 5
      pm.start_servers = 2
      pm.min_spare_servers = 1
      pm.max_spare_servers = 3





      share|improve this answer


























        0












        0








        0







        I faced similar kind of problem and i ended up increasing number of php-fpm workers. I used the following settings in www.conf (pool.d) to solve the problem i was facing. I had an analytics server setup which was tracking pageviews and there was a delay of 15-20s in API recording the pageviews. Tuning the following settings solved my problem, maybe it might help you.



        pm = dynamic
        pm.max_children = 5
        pm.start_servers = 2
        pm.min_spare_servers = 1
        pm.max_spare_servers = 3





        share|improve this answer













        I faced similar kind of problem and i ended up increasing number of php-fpm workers. I used the following settings in www.conf (pool.d) to solve the problem i was facing. I had an analytics server setup which was tracking pageviews and there was a delay of 15-20s in API recording the pageviews. Tuning the following settings solved my problem, maybe it might help you.



        pm = dynamic
        pm.max_children = 5
        pm.start_servers = 2
        pm.min_spare_servers = 1
        pm.max_spare_servers = 3






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 2 '18 at 21:51









        Mohd Asim SuhailMohd Asim Suhail

        1011




        1011






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Server Fault!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f681861%2fnginx-php-fpm-ajax-slow-first-request-good-next-ones%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Фонтен-ла-Гаярд Зміст Демографія | Економіка | Посилання |...

            Список ссавців Італії Природоохоронні статуси | Список |...

            Маріан Котлеба Зміст Життєпис | Політичні погляди |...