Building Scalable Apps with Redis and Node.js
eBook - ePub

Building Scalable Apps with Redis and Node.js

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

Building Scalable Apps with Redis and Node.js

About this book

Node.js is a JavaScript runtime-based, scalable platform used to develop web applications and network programs on the server side. It allows web designers to access the backend of their projects while also allowing developers, who are willing to learn JavaScript, a chance to design. There are many frameworks that have popped up in recent years, but what makes Node.js unique is that it opens up a whole new frontier for web development and takes a hybrid approach.

This book will help you get to grips with Node.js and implement the knowledge to build efficient web applications. You start with developing a backend web application followed by a frontend interface, and later on deploy it to the cloud platform. This book takes a holistic approach to server-side programming using Node.js in conjunction with different frameworks and tools.

Trusted by 375,005 students

Access to over 1 million titles for a fair monthly price.

Study more efficiently using our study tools.

Information

Year
2014
Edition
1
eBook ISBN
9781783984480

Building Scalable Apps with Redis and Node.js


Table of Contents

Building Scalable Apps with Redis and 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
Downloading the color images of this book
Errata
Piracy
Questions
1. Backend Development with Express
Node.js and Node Package Manager
Using Express in Node
Using middleware in Express
Creating our own middleware
Adding templates to the mix
Layouts
Using sessions in Express
Using cookies in Express
Adding sessions
Redis as a session store
Processing forms
Cross-Site Request Forgery (CSRF)
Very simple authentication
Setting up a config file for our app
Route mapping
Updating our app to use the config
Methods to extend an application
Summary
2. Extending Our Development with Socket.IO
Node package versions
Building a simple Socket.IO app
Installing the package
Building the client
Using Python to serve our site
Ping-Pong
Creating some interaction
Adding the browser side
Acknowledgments
Broadcasting a message
Using the disconnect event
Creating namespaces
Building our namespace client
Adding rooms
Using namespaces or rooms
Namespaces
Finding namespaces
When to use rooms
Finding rooms
Using namespaces and rooms together
Using Socket.IO and Express together
Adding Socket.IO to the config
Who are you?
Authorization in Socket.IO
Using the authorization handler
Cookies and sessions
Getting the session
Adding application-specific events
Using Redis as the store for Socket.IO
Socket.IO inner workings
WebSockets
Ideas to take away from this chapter
Summary
3. Authenticating Users
Node package versions
Let's build our authentication
Registering a Facebook application
Using Passport to authenticate to Facebook
Using Google for authentication
Adding Google authentication to our application
Adding more OAuth providers
Adding secure local authentication
Adding registration
Adding a database
Password-storing theory
OAuth process
Summary
4. RabbitMQ for Message Queuing
Node package versions
Getting RabbitMQ
Installing on Mac OS X
The RabbitMQ management plugin
Installing on Linux
Installing on Windows
Our first message queue
Using the management interface
Sending messages
Queuing messages
Adding another worker
Sending messages back
Creating StartServer
Building the worker
Charging cards in real time
Adding message queues to PacktChat
Topic exchange
Building the worker
Message queuing in RabbitMQ
Summary
5. Adopting Redis for Application Data
Node package versions
Installing Redis
Installing on Mac OS X
Installing on Linux
Installing on Windows
Using Redis data structures
Building a simple Redis application
Redis schema
Using a hash
Keys in Redis
Redis persistence
Removing Redis keys
Using Redis as a message queue
Adding Redis to PacktChat
Defining the Redis structures
Creating our Redis functions
Redis is for application state
Summary
6. Using Bower to Manage Our Frontend Dependencies
Node package versions
Installing and using Bower
Introducing React
Introducing Backbone
Using Backbone models
Using Backbone collections
Summary
7. Using Backbone and React for DOM Events
Bower package versions
Finishing Socket.IO
Creating React components
React summary
Backbone models
Syncing the models with Socket.IO
Creating the model
Creating collections
The Backbone router
Putting it all together
Updating CSS and the layout
Adding a new worker
Trying out our application
Summary
8. JavaScript Best Practices for Application Development
Node package versions
Setting up tests
Using Istanbul for code coverage
Setting up different environments
Twelve Factor App
Fixing the config file
Creating our environment files
Adding more environments
Introducing Grunt
Building a basic Grunt file
Automating our tests
Preprocessing our files
Using Grunt to clean out a folder
JSHinting our source files
Concatenating our code
Minifying our code
Grunt summary
Static files and CDNs
Creating an S3 bucket
Python and installing virtual environments
Scripting our new tools
Summary
9. Deployment and Scalability
Creating servers on EC2
AWS EC2 summary
What is Ansible?
Installing Ansible
Using Ansible roles
Installing RabbitMQ
Installing our application
Deploying the code
Installing the workers
Load balancing multiple application servers
Automating roles
A summary of Ansible
Creating new environments
Scalability
Different types of scalability
Horizontal
Vertical
Summary
10. Debugging and Troubleshooting
Node packages
Using Chrome Developer Tools
Elements
Network
Sources
Timeline
Profiles
Resources
Audits
Console
Inspecting requests
Debugging
Frontend debugging
Backend debugging
Debugging summary
CPU profiling our application
Taking heap snapshots
Frontend memory leaks
Memory leak summary
Summary
Index

Building Scalable Apps with Redis and Node.js

Copyright © 2014 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: September 2014
Production reference: 1190914
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78398-448-0
www.packtpub.com
Cover image by Siddhart Ravishankar ()

Credits

Author
Joshua Johanan
Reviewers
Harrison Dahme
Sven Kreiss, PhD
Andrew Long
Jari Timonen
Commissioning Editor
Kunal Parikh
Acquisition Editor
Richard Harvey
Content Development Editor
Arun Nadar
Technical Editors
Kunal Anil Gaikwad
Shruti Rawool
Copy Editors
Mradula Hegde
Dipti Kapadia
Sayanee Mukherjee
Deepa Nambiar
Alfida Paiva
Project Coordinator
Neha Bhatnagar
Proofreaders
Simran Bhogal
Lauren Harkins
Linda Morris
Indexers
Rekha Nair
Priya Sane
Graphics
Sheetal Aute
Production Coordinator
Nitesh Thakur
Cover Work
Nitesh Thakur

About the Author

Joshua Johanan is a web developer who currently lives in South Bend, Indiana. He has been a web developer for 5 years. He has built sites using many different languages, including PHP, Python, JavaScript, and C#, although if asked, he would prefer using Python and JavaScript. These languages have led him to use different MVC frameworks such as Zend Framework, Django, and .NET's MVC.
As you can tell from this book, he has u...

Table of contents

  1. Building Scalable Apps with Redis and Node.js

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
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 990+ topics, we’ve got you covered! Learn about our mission
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 about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Building Scalable Apps with Redis and Node.js by Joshua Johanan in PDF and/or ePUB format, as well as other popular books in Ciencia de la computación & Desarrollo de aplicaciones. We have over one million books available in our catalogue for you to explore.