Why is my default mean app running so slow?

January 10, 2017 937 views
MEAN Nginx Node.js Ubuntu 16.04

I created a 1gb droplet with the one click app selection of Mean 0.5.0 on Ubuntu 16.04. I bought a domain name and I'm using nginx to create a proxy server that routes to the default mean application under /opt/mean. I navigate to /opt/mean and run npm start to start the web server. When I open the page in the browser it takes up to 25 seconds to load my website. Here is the output from the server when I request the website. When I try to load the page, it gets to the line that requests users.client.service.js and gets stuck there for a really long time before finally loading the page. My guess is that I'm doing something wrong setting up nginx?

info: GET /modules/users/client/services/password-validator.client.service.js 304 0.695 ms - -

info: GET /modules/users/client/services/users.client.service.js 304 0.565 ms - -

info: GET /modules/core/client/views/header.client.view.html 304 0.730 ms - -

info: GET /modules/core/client/views/home.client.view.html 304 0.491 ms - -

I also changed the nginx default file under sites-enabled to the following

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        server_name MYDOMAIN.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                #try_files $uri $uri/ =404;
                proxy_pass http://MYIPADDRESS;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;

1 Answer
jtittle1 January 10, 2017
Accepted Answer


It's definitely not your NGINX configuration. I just deployed a test droplet with the same configuration and I'm experiencing the same extended delays. The default application is meant more so for testing, though shouldn't be performing that poorly in any case.

What I'd do is submit a support ticket requesting assistance. Provide them with a link to a screenshot of the output from the CLI as well, that way they have some numbers to work with.

On my end, I'm seeing delays of up to 326ms.

  • I just tried doing the same thing with the Ubuntu 14.04 One-Click mean application and it's working fine. I'll submit a support ticket though so that they know it's a problem.

  • I had the same issue. check your middleware, maybe you have sessions talking to databases per request slowing down the pipeline. Make sure your static middleware is before those.

    app.use(express.static(path.join(__dirname, 'public')));
Have another answer? Share your knowledge.