NuxtJS deployment using CircleCi CPU spikes 100%+

I am deploying my NuxtJS app using a deployment script, which I added below. I use some of the instructions from this tutorial:

If I access my droplet using SSH and run the script manually, it seems to work fine. But as soon as CircleCI starts a docker instance (see config.yml below), it needs at least 5 minutes to run the script, if I am lucky. And while doing that, the CPU of my droplet spikes, and it takes a lot of patience trying to reconnect with my droplet using SSH from my local machine.

Quite odd this only happens when running the script through CircleCI. I tried to spin up a medium docker instance, instead of a small, but without luck. Most of the time, the deployment is killed after 10 minutes, so I end up with a failed deployment most of the time.

If CircleCI fails, my droplet’s CPU stays over 100% and node_modules/.bin/nuxt build keeps running. Rebooting the droplet is the easiest solution (sometimes necessary, if reconnecting using SSH just isn’t possible or the terminal which is already connected, isn’t responding anymore). After reboot, the first CircleCi deployment succeeds and the rest fail again.

I looked at htop, and it seems that kswapd0 takes over 40% CPU, snapd over 30 and the rest are for node, etc.


#move to project folder
cd /var/www/

#pull from the branch
git pull origin main

# build nuxt project and run pm2
npm install
npm run build

pm2 start

circleci config.yml

version: 2.1

      - image: buildpack-deps:trusty
    resource_class: small   # we use a small docker instance to use as little credits as possible
      - add_ssh_keys:
            - "xx:xx:xx:xx:xx:xx:xx:xx"
      - run:
          name: Deploy Over SSH
          command: |
              ssh -oStrictHostKeyChecking=no -v $SSH_USER@$SSH_HOST "./"
      - deploy:
                - main # only deploy on the main branch

Any thoughts?

My droplet: 1 GB Memory / 25 GB Disk / AMS3 - Ubuntu 20.04 (LTS) x64

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Solved it: Saving some memory for other processes, by setting the --max-old-space-size parameter on the build process in package.json seems to solve this. My app was deployed in under a minute.

"build": "node --max-old-space-size=600 node_modules/nuxt/bin/nuxt.js build"