Deploying Node.js
eBook - ePub

Deploying Node.js

Sandro Pasquali

Share book
  1. 274 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Deploying Node.js

Sandro Pasquali

Book details
Book preview
Table of contents
Citations

About This Book

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.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Deploying Node.js an online PDF/ePUB?
Yes, you can access Deploying Node.js by Sandro Pasquali in PDF and/or ePUB format, as well as other popular books in Informatique & Informatique client-serveur. We have over one million books available in our catalogue for you to explore.

Information

Year
2015
ISBN
9781783981403

Deploying Node.js


Table of Contents

Deploying Node.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Appreciating Node
Understanding Node's unique design
Concurrency
Parallelism and threads
Concurrency and processes
Events
The event loop
The implications of Node's design on system architects
Building large systems out of small systems
Streams
Using full-stack JavaScript to maximum effect
Hot code
Browserify
Summary
2. Installing and Virtualizing Node Servers
Getting a basic Node server up and running
Hello world
Making HTTP requests
Proxying and tunneling
HTTPS, TLS (SSL), and securing your server
Creating a self-signed certificate for development
Installing a real SSL certificate
Installing applications on Heroku
Add-ons
Git
Managing configuration variables
Managing your deployment
Installing applications on OpenShift
Installing a Node application and MongoDB
Deploying your app
Using Docker to create lightweight virtual containers
First, some Unix
Getting started with Docker
Creating a Dockerfile
Building and running a Docker image
Summary
3. Scaling Node
Scaling vertically across multiple cores
spawn(command, [arguments], [options])
fork(modulePath, [arguments], [options])
exec(command, [options], callback)
execFile
Communicating with your child process
child.connected
child.stdin
child.stdout
child.stderr
child.pid
child.kill([signal])
child.disconnect()
child.send(message, [sendHandle])
The cluster module
cluster.isMaster
cluster.isWorker
cluster.worker
cluster.workers
cluster.setupMaster([settings])
cluster.fork([env])
cluster.disconnect([callback])
cluster events
worker.id
worker.process
worker.suicide
worker.send(message, [sendHandle])
worker.kill([signal])
worker.disconnect()
Scaling horizontally across different machines
Using Nginx
Deploying an Nginx load balancer on DigitalOcean
Installing and configuring Nginx
Load balancing with Node
Using node-http-proxy
Using message queues
Using Node's UDP Module
Summary
4. Managing Memory and Space
Dealing with large crowds
Microservices
Redis pub/sub
Microservices with Seneca
Reducing memory usage
Use streams, not buffers
Understanding prototypes
Memory-efficient data structures with Redis
Using bitwise operations to analyze user actions over time
Setting, getting, and counting bits
Bitmasks and filtering results
Using HyperLogLog to count unique anonymous visitors
Taming V8 and optimizing performance
Optimizing JavaScript
Numbers and tracing optimization/de-optimization
Objects and arrays
Functions
Caching strategies
Using Redis as a cache
Deploying CloudFlare as a CDN
Managing sessions
JSON Web Token authentication and sessions
Summary
5. Monitoring Applications
Dealing with failure
The 'domain' module
Catching process errors
Logging
Logging with UDP
Logging with Morgan
Modifying behavior in changing environments
Node REPL
Remotely monitoring and managing Node processes
Profiling processes
Using third-party monitoring tools
PM2
Monitoring
Nodetime
Using New Relic for monitoring
Summary
6. Building and Testing
Building with Gulp, Browserify, and Handlebars
Using Gulp
Erecting a build scaffold
Running and testing your build
Using Node's native testing tools
The Node debugger
The 'assert' module
Testing with Mocha, Chai, Sinon, and npm
Mocha
Chai
Sinon
Spies
Stubs
Mocks
Automated browser testing with PhantomJS and CasperJS
Headless testing with PhantomJS
Navigation scenarios with CasperJS
Summary
7. Deploying and Maintaining
Using GitHub webhooks
Enabling webhooks
Implementing a build/deploy system using webhooks
Synchronizing local and deployed builds
Developing locally with Vagrant
Provisioning with Ansible
Integrating, delivering, and deploying
Continuous integration
Continuous delivery
Continuous deployment
Building and deploying with Jenkins
Deploying to Heroku
Package maintenance
Understanding Semver
Managing packages with npm
Designing a dependency tree
Summary
Index

Deploying Node.js

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: July 2015
Production reference: 1170715
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78398-140-3
www.packtpub.com

Credits

Author
Sandro Pasquali
Reviewers
Benjamin Bahrenburg
Nikola BreĆŸnjak
FĂ©lix Saparelli
Jim Schubert
Commissioning Editor
Edward Gordon
Acquisition Editor
Meeta Rajani
Content Development Editor
Rohit Kumar Singh
Technical Editor
Humera Shaikh
Copy Editor
Sarang Chari
Project Coordinator
Mary Alex
Proofreader
Safis Editing
Indexer
Mariammal Chettiyar
Production Coordinator
Conidon Miranda
Cover Work
Conidon Miranda

About the Author

Sandro Pasquali, in 1997, formed Simple.com, a technology company that sold the world's first JavaScript-based application development framework and was awarded several patents for deployment and advertising technologies that anticipated the future of Internet-based software. Node represents, for him, the natural next step in the inexorable march toward the day when JavaScript powers nearly every level of software development.
Sandro has led the design of enterprise-grade applications for some of the largest companies in the world, including Nintendo, Major League Baseball, Bang and Olufsen, LimeWire, AppNexus, Conde Nast, and others. He has displayed interactive media exhibits during the Venice Biennial, won design awards, built knowledge management tools for research institutes and schools, and started...

Table of contents