Building Scalable Apps with Redis and Node.js
图书信息
| 作者 | Joshua Johanan |
| 出版社 | Packt Publishing |
| ISBN | 9781783984497 |
| 出版时间 | 2014-09-25 |
| 字数 | 144.4万 |
| 分类 | 进口书,外文原版书,电脑,网络 |
读书简介
If the phrase scalability sounds alien to you, then this is an ideal book for you. You will not need much Node.js experience as each framework is demonstrated in a way that requires no previous knowledge of the framework. You will be building scalable Node.js applications in no time! Knowledge of JavaScript is required.
目录
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
- 合同解除制度研究(李晓钰)
- 儿童英语启蒙——从绘本、游戏到分级读物(施乐遥)
- 中国企业家成长30年:企业家精神引领企业迈向高质量发展(李兰)
- 县域经济破局:数智化驱动县域发展新模式(刘丁蓉,华崇鑫,朱建良)
- 分开以后我变成了你喜欢的样子(Josie乔)
- 葛冰动物童话·飞熊“佐罗”(葛冰)
- Delphi Collected Poetical Works of John Gower (Illustrated)(John Gower)
- 建设工程监理案例分析(仅适用PC阅读)(执业资格考试命题研究中心)
