×
Community Blog How to Deploy Node.js Application? Configuration and Troubleshooting

How to Deploy Node.js Application? Configuration and Troubleshooting

In this tutorial, you will learn to deploy Node.js application on servers like CentOS, and some commonly troubleshooting in apps configuration.

Node.js is a Javascript runtime environment used to build high-performance and fast server-side applications. Node.js server-side applications, if deployed in the wrong way could become really slow and not be able to support a growing traffic.

In this tutorial, we will cover setting up a production-ready Node.js application using the amazing services provided by Alibaba Cloud services. We'll be deploying an application called Node.js Blog, and to do this, we'll be using the following Alibaba Cloud services:

  1. Elastic Compute Service: A virtual computing environment that includes the CPU, memory, OS, bandwidth, disks, and other basic computing components. We'll use this service to launch a Linux instance, to which we'll deploy our Node.js application.
  2. ApsaraDB for MongoDB: A secure, reliable, and elastically scalable cloud database service. We'll use this service to launch a MongoDB database for our Node.js application.

Prerequisites

Before you begin this tutorial you'll need the following:

  1. The Node.js application we'll be deploying. You can find it on this Github repository
  2. An Ubuntu 16.04 64 bit ECS instance. You can create one using this tutorial.
  3. An ApsaraDB for MongoDB instance. You can create one using this tutorial.
  4. Successfully connect to your ECS instance. To connect using SSH, you can follow this tutorial.

Note: Make sure the ECS instance and the ApsaraDB for MongoDB instance are created in exactly the same zone. This will improve application performance and also avoid any connection issues or restrictions.

Step 1 - Installing All Server Dependencies

In this step, we'll be installing all the dependencies we need to be able to run our node js application. To follow along, make sure you are logged in to your ECS instance.

To learn the following steps of installing Git and etc,you can refer to Deploying Node.js Apps for Production on Alibaba Cloud.

Related Blogs

How to Deploy a Node.js Application on CentOS with Alibaba Cloud Starter Package

This tutorial shows you how to deploy a Node.js application on a CentOS server using Alibaba Cloud's Starter Package service.

If you are planning to host a Node.js application or dynamic website on Alibaba Cloud, then an optimal and economical solution with high bandwidth, SSD and powerful CPU might interests you. Introducing Alibaba Cloud's Starter Package Program, which provides SSD Cloud servers powered by 2nd Generation Intel Xeon Scalable Processors at highly affordable prices compared to other cloud providers. It allows you to access a powerful CPU at a much lower cost and supports both, Linux and Windows servers worldwide.

Alibaba Cloud's Starter Package helps you get started instantly through simple, scalable, and cost-effective Elastic Compute Service (ECS) that caters to all your cloud hosting needs. The new SSD Cloud Server Packages provide easy-to-use, high-performance virtual machines with higher data transfer plans at hugely discounted rates for enabling you to start from as low as $2.50 a month. Since it is available across 14 global regions, you can easily choose the Datacenter Region for your servers to meet any specific requirements. It allows each user to have up to five ECS instances with the simultaneous Data Transfer Plans.

So, once you have reserved your SSD Cloud Server via Starter Package 2.0, you can go ahead and easily deploy a Node.js project on CentOS operating system by following the instructions below:

Prerequisites

To build your dynamic website by deploying a Node.js project on CentOS, you should meet the following requirements:

  1. Alibaba Cloud account. In case you don't already have one, set up an account before continuing
  2. SSH like PuTTy or RDP client (optional) installed on your computer

Creating a React JS Application Image with Packer and Ansible on Alibaba Cloud

In this guide, we will talk about using Packer to build a machine image on Alibaba Cloud ECS instance, and Ansible for writing what we want our machine image to have.

Packer is an open source tool for creating identical machine images for multiple platforms from a single source configuration. Packer is lightweight, runs on every major operating system, and is highly performant, creating machine images for multiple platforms in parallel.

Ansible is an open source software that automates software provisioning, configuration management, and application deployment. Ansible connects via SSH, remote PowerShell or via other remote APIs.

In this guide, we will talk about using Packer to build a machine image on Alibaba Cloud Elastic Compute Service (ECS), and Ansible for writing what we want our machine image to have. We will be building an image that has a react JS application and nodejs setup. Machine image in DevOps is a single static unit that contains a pre-configured operating system and installed software which is used to quickly create new running machines. Machine image formats change for each platform.

Prerequisites

You don't need to be an expert to follow this guide, All you need to have is an account on Alibaba Cloud and an Access key. Click on this link to see how to create an access key on Alibaba cloud.

Step 1: Install Packer

To install packer on our system, we can follow the official installation page for packer or use a package manager, chocolatey for windows and homebrew for macOS. Using a package manager saves us from the hassle of adding environment variables to path.

Node.js Application Troubleshooting Manual - Node.js Performance Platform User Guide

In this Node.js troubleshooting series, we will describe the features and best practices of Node.js Performance Platform for Node.js applications.

Introduction

In the previous article, we used Chrome DevTools to troubleshoot CPU and memory problems in Node.js applications. However, in actual production practices, we may find that Chrome DevTools is more inclined to local development because it obviously does not generate dump files, which are required for problem analysis. This means that developers additionally need to configure tools like v8-profiler and heapdump for online projects and export statuses of projects running online in real time by using additionally implemented services.

In addition to CPU and memory problems described in the previous article, in some scenarios, we may need to analyze error logs, disks, and core dump files to eventually locate problems. In these scenarios, Chrome DevTools alone may not be able to meet the requirements. To solve those pain points for Node.js developers, we recommend Node.js Performance Platform (formerly known as AliNode). Node.js Performance Platform has already been used to monitor and troubleshoot almost all of Alibaba Group's online Node.js applications. You can deploy and use it in your production environment without any worries.

This article describes the architecture, core capabilities, best practices, and other aspects of Node.js Performance Platform to help developers understand how to use this tool to analyze abnormal metrics and troubleshoot online Node.js application faults.

This manual is first published on GitHub at https://github.com/aliyun-node/Node.js-Troubleshooting-Guide and will be simultaneously updated to the community.

Note: At the time of writing, the Node.js Performance Platform product is only available for domestic (Mainland China) accounts.

Related Courses

Operate and Manage a Cloud Server

Understand the advantage of a cloud server. Learn how to purchase ECS on Alibaba Cloud, manage the server on our console, backup critical data and ensure your system can adjust according to business needs.

Cloud Servers Security Strengthening

For the security measures of the host on the cloud, we need to consider more factors, such as the configuration of the firewall inside the host, as well as various settings related to operating system user management and privilege management. Only by understanding and correctly configuring the security settings inside these hosts you can better cooperate with various cloud security products. This course is designed to help you better understand these security setup and learn how to properly configure them to maximize the security hardening of hosts on the cloud.

Related Market Products

OpenCart powered by Websoft9(Simple Application Server)

Websoft9 OpenCart is a pre-configured, ready to run image for running OpenCart on Alibaba Cloud. is an easy to-use, powerful, open source online store management program that can manage multiple online stores from a single back-end.

Ghost powered by Websoft9(Simple Application Server)

Websoft9 Ghost is a pre-configured, ready to run image for running Ghost on Alibaba Cloud.Ghost is an open source platform for building and running a modern online publication.

Related Documentation

JS SDK Introduction - Blockchain as a Service

JavaScript SDK (JS SDK) connects the blockchain business and the blockchain platform. It provides basic API operations, such as submitting transactions, performing operations on accounts, deploying and calling contracts, performing query operations, executing local transactions, and listening to events. The JS SDK uses TLS and HTTPS protocols to interact with the blockchain platform, and standardizes API operation calls.

The JS SDK is easy to use and can be integrated in the Node.js environment or other environments, such as browsers or web applications. Node.js is required when you call the JS SDK that uses the TLS protocol. You can call the JS SDK directly in the browser when the HTTPS protocol is used.

What is Simple Application Server?

Simple Application Server suits you well if all you need is a private virtual machine. It provides you the all-in-one solution to launch and manage your application, set up domain name resolution, and build, monitor, maintain your website with just a few clicks. It makes private server building much easier, and it is the best way for beginners to get started with cloud computing.

Related Products

Simple Application Server

Simple Application Server is a new generation computing service for stand-alone application scenarios. It provides one-click application deployment and supports all-in-one services such as domain name resolution, website publishing, security, O&M, and application management. This optimizes the user experience of setting up a simple application and makes it easier for entry-level users to use cloud computing products.

Elastic Compute Service

Alibaba Cloud Elastic Compute Service (ECS) provides fast memory and the latest Intel CPUs to help you to power your cloud applications and achieve faster results with low latency.

Deploy ECS instances with just a few clicks from the easy-to-use console and scale capacity up or down based on real-time demands.

0 0 0
Share on

Alibaba Clouder

2,605 posts | 747 followers

You may also like

Comments