Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Deploying Node.js
Deploying Node.js

Deploying Node.js: Learn how to build, test, deploy, monitor, and maintain your Node.js applications at scale

eBook
AU$14.99 AU$53.99
Paperback
AU$67.99
Subscription
Free Trial
Renews at AU$24.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Deploying Node.js

Chapter 2. Installing and Virtualizing Node Servers

Recall the story from Chapter 1, Appreciating Node, about how Walmart ran all of its Black Friday mobile traffic through Node, which was deployed across the equivalent of 2 CPUs and 30 gigs of RAM. This demonstrates that Node processes I/O so efficiently that even Walmart-level traffic on Black Friday can be handled with only a few servers. This means that, for many people, running your Node application on a single server is all you'll ever need to do.

Nevertheless, it is often good to have several servers at your disposal, such as redundant servers to ensure failover recovery, a distinct database server, specialized media servers, one hosting a message queue, and so on. In keeping with the idea of separating concerns into many independent processes, Node-based applications are often composed of many lightweight servers spread across a data center, possibly even spread across several data centers.

In this chapter, we will...

Getting a basic Node server up and running

HTTP is a data transfer protocol built upon a request/response model. Normally, a client makes a request to a server, receives a response, makes another request, and so on. HTTP is stateless, which simply means that each request or response maintains no information on previous requests or responses. Facilitating this sort of rapid-pattern network communication is the sort of I/O that Node is designed to excel at. While Node represents a much more interesting technology stack overall, it does help engineers in creating networked protocol servers. In this section, we will move through a general overview of how to set up a basic HTTP server and then into a few more specialized uses of the protocol.

Hello world

An HTTP server responds to connection attempts and manages data as it arrives and as it is sent along. A Node server is typically created using the createServer method of the HTTP module:

var http = require('http');

var server = http...

Installing applications on Heroku

Heroku is a mature PaaS cloud-hosting solution that supports the development of Node applications. To get started, visit http://www.heroku.com and submit an e-mail address. Heroku is free to start with. After you've confirmed your account, you can start deploying apps right away.

Scaling Heroku applications involves increasing the number of dynos that you are paying for. Each dyno is an isolated container running your application and you are able to increase or decrease the number of dynos your application uses with ease. In this way, there aren't any hosting packages to buy—you simply scale as needed by asking for more, or fewer, dynos.

Heroku allows you to deploy applications on many platforms and languages—it is not Node-centric. This is something to keep in mind should you anticipate the need to add services to your application not written in Node.

To control Heroku remote instances, you will use a local utility belt application...

Installing applications on OpenShift

Red Hat, the enterprise Linux company, operates OpenShift, a cloud-hosting solution. OpenShift offers several options for how you want to deploy your apps—via a web-based interface, via the command line, or through an online IDE. As we've worked on the command line for our other deployment examples, we'll do the same with OpenShift.

Once you've joined and confirmed your account, you will need to install the OpenShift client tools—rhc. For the purposes of this section, I'll use the Mac OS X client. Regardless of which package you happen to choose, the command set remains the same:

sudo gem install rhc
gem update rhc

This will install the client and update it to the latest version.

Once installed, you will need to set up your SSH keys and authenticate with the system by running an rhc setup. Just enter your authentication information, confirm the installation of keys, and confirm the upload of credentials.

You will then be...

Using Docker to create lightweight virtual containers

This image from the Docker website (http://www.docker.com/) gives information on how and why the Docker team feels their technology fits into the future of application development:

Using Docker to create lightweight virtual containers

The preceding image, concisely describing the generational shift in application architecture we are now experiencing, can just as easily be used to describe the how and why of Node's design.

Docker, according to the website, …is an open source engine that automates the deployment of any application as a lightweight, portable, self-sufficient container that will run virtually anywhere. Once you have created a Docker image of your application, a running instance of that image can be spun in milliseconds. Yes, that's right: a few milliseconds. Docker lets you create even hundreds of deployments of your application in a few seconds.

The Docker ecosystem has three main components. Here's some information about the components from the documentation...

Summary

In this chapter, you learned how to create Node servers and applications, both locally and in the cloud. Having deployed a simple document-editing application using Node and MongoDB across three different PaaS providers, you have an early sense of what is available to the Node developer who is looking to scale their application. You were introduced to Docker, which offers a powerful new containerization technology, allowing us to make many cheap clones of our applications; wherever there is Linux, there exists a deploy target for Docker.

In the next chapter, we will take these simple ideas about scaling farther and deeper by exploring in more detail how Node can be scaled both vertically and horizontally—across cores and across many machines.

Left arrow icon Right arrow icon

Description

If you are an intermediate or advanced developer deploying your Node.js applications, then this book is for you. If you have already built a Node application or module and want to take your knowledge to the next level, this book will help you find your way.

Who is this book for?

If you are an intermediate or advanced developer deploying your Node.js applications, then this book is for you. If you have already built a Node application or module and want to take your knowledge to the next level, this book will help you find your way.

What you will learn

  • Learn the strengths of Node.js and how to optimize your code to make it ready for deployment into production
  • Use Docker and Vagrant to create many virtual instances of your Node.js applications
  • Deploy Node.js repositories to the cloud using Heroku, OpenShift, and DigitalOcean
  • Utilize native Node.js modules, or Nginx, to load balance your applications
  • Optimize your Node runtime by tweaking V8, managing memory intelligently, and using Redis to manage state data
  • Discover how to use Gulp, Browserify, npm, Mocha, Chai, Sinon, and other tools to simplify your build/test/release process
  • Manage your production deployments with Git, Jenkins, and Ansible

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 23, 2015
Length: 274 pages
Edition : 1st
Language : English
ISBN-13 : 9781783981410
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Jul 23, 2015
Length: 274 pages
Edition : 1st
Language : English
ISBN-13 : 9781783981410
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
AU$24.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
AU$249.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just AU$5 each
Feature tick icon Exclusive print discounts
AU$349.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just AU$5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total AU$ 211.97
Node.js By Example
AU$67.99
Node.js Design Patterns
AU$75.99
Deploying Node.js
AU$67.99
Total AU$ 211.97 Stars icon
Banner background image

Table of Contents

8 Chapters
1. Appreciating Node Chevron down icon Chevron up icon
2. Installing and Virtualizing Node Servers Chevron down icon Chevron up icon
3. Scaling Node Chevron down icon Chevron up icon
4. Managing Memory and Space Chevron down icon Chevron up icon
5. Monitoring Applications Chevron down icon Chevron up icon
6. Building and Testing Chevron down icon Chevron up icon
7. Deploying and Maintaining Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.7
(6 Ratings)
5 star 66.7%
4 star 33.3%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Wilson Sep 15, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I recommend this book to anyone who is struggling about what things to know about deploying a real Node.js application in production, very good insights and advice about real situations that you can encounter in your day a day Node.JS work. So if you really want to have a Node.JS app deployed properly with good practices, pick up this book.
Amazon Verified review Amazon
poplinr Mar 03, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Want to really understand how Node applications should be built, maintained, tested, and deployed? I think this is the only one-stop resource I've found on these industry required topics; it's a required reading book as far as I'm concerned. Seriously; the stuff you learn in this book is what interviewers are looking for on jobs which is nice, too.Understanding of intermediate JavaScript concepts is required (Understand OOP in JavaScript).
Amazon Verified review Amazon
Justin R Hildreth Sep 14, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book provides a good balance of detail, from high-level overviews to low-level implementation details. It does also cover some of how Node.js works, both at its core as well as specific features relevant to writing applications that will be easier/more successful to deploy. Due to the ranges of both level of detail as well as subject matter, I did at times feel like the flow of the book was a bit meandering. Still, it contains some great information, and will be helpful to anyone building and deploying Node.js applications.
Amazon Verified review Amazon
Nikola Dec 28, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book covers a lot of topics and, in my opinion, it is not suited for beginners in the field, but for those who have some experience with Node.js and other tools.However, it's great that a simple introduction is given to all these topics so that one who is interested more in some particular section, can easily build upon the knowledge gained from the book.The author clearly shows how a Node.js app should be built, tested, monitored, deployed, scaled and maintained.
Amazon Verified review Amazon
Jim Fathman Oct 31, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
The thriving Node.js ecosystem encourages open collaboration where components do not originate from a single source, but where module writers build on each other's work, in layers. This is a powerful development model which encourages improvement and refinement for the best results, but it can be hard to arrive on the scene later and make sense of it all. This book is useful to help tie everything together.This book might have been titled Node.js Notebook as it touches on so many topics. The breadth is appropriate because you really will encounter these many technologies and more when developing and deploying Node.js applications. The brevity with which some topics are dealt may leave you wanting, but the introductory coverage is useful and will get you started in the right direction.Node.js applications typically employ may modules and external technologies, where each has available documentation, but it can be challenging to find overarching documentation that outlines how to combine everything. This book helps with the big picture. The section on Mocha, Chai, and Sinon is particularly good at explaining how these modules complement each other.Strong points in this book include the modules and technologies selected, and the rich and correct use of related terminology. You can use and repeat what you learn here with confidence.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.