No More Mr. Nice Guy The MEAN Stack
-
Upload
will-button -
Category
Software
-
view
370 -
download
7
Transcript of No More Mr. Nice Guy The MEAN Stack
![Page 1: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/1.jpg)
No More Mr. Nice Guy
The MEAN Stack
![Page 2: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/2.jpg)
What we will coverFault toleranceScalabilityPerformance
MongodbExpress.jsAngularNode.js(a.k.a. the MEAN stack)
![Page 3: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/3.jpg)
What we won't coverDetailed implementation
![Page 4: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/4.jpg)
Why the MEAN stack?MongodbExpress.jsAngularNode.js
CassandraReactAWS API GatewayPython
![Page 5: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/5.jpg)
Goals of a Highly Available EnvironmentFault toleranceScalablePerformance
Programming today is a race between software engineers striving to build bigger and better idiot-proof
programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.-- Rick Cook, The Wizardry Compiled (1989)
![Page 6: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/6.jpg)
Building Our Environment
PM2 { “apps”: [{ “name”: “App1”, “script”: “server.js” “instances”: 0, “max_memory_restart”: “2G” }]}
Node.js
![Page 7: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/7.jpg)
Scaling Node.js
Node.js Node.js Node.js
Elastic Load Balancer
![Page 8: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/8.jpg)
Use The VPC, Luke
Node.js Node.js Node.js
Elastic Load Balancer
![Page 9: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/9.jpg)
Availability Zone CAvailability Zone BAvailability Zone A
Geographical Fault Tolerance
Node.js Node.js Node.js
Elastic Load Balancer
![Page 10: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/10.jpg)
Availability Zone CAvailability Zone BAvailability Zone A
Adding Our MongoDB Servers
MongoDB1 MongoDB2 MongoDB3
Node.js Node.js Node.js
Elastic Load Balancer
![Page 11: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/11.jpg)
Availability Zone CAvailability Zone BAvailability Zone A
MongoDB Fault Tolerance
MongoDB1 MongoDB2 MongoDB3MongoDB1 MongoDB2 MongoDB3
Node.js Node.js Node.js
Elastic Load Balancer
module.exports = { db: 'mongodb://MongoDB1/myApp,MongoDB2/myApp,MongoDB2/myApp', dbOptions: { server: { replset: { rs_name: 'myReplicaSet', readPreference: 'nearest' } }
![Page 12: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/12.jpg)
EuropeUnited StatesChina
Scaling MongoDB
MongoDB1MongoDB1
MongoDB1
MongoDB1MongoDB2
MongoDB2
MongoDB1MongoDB3
MongoDB3MongoDB1 MongoDB2 MongoDB3
Node.js Node.js Node.js
Elastic Load Balancer
![Page 13: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/13.jpg)
EuropeUnited StatesChina
Scaling MongoDB
MongoDB1MongoDB1
MongoDB1
MongoDB1MongoDB2
MongoDB2
MongoDB1MongoDB3
MongoDB3MongoDB1 MongoDB2 MongoDB3
Node.js Node.js Node.js
Elastic Load Balancer
MongoDB || Cassandra || MySql || Postgresql || Couchdb || etc...
![Page 14: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/14.jpg)
Breaking The Bank
Availability Zone CAvailability Zone BAvailability Zone A
MongoDB1 MongoDB2 MongoDB3MongoDB1 MongoDB2 MongoDB3
Node.js Node.js Node.js
Elastic Load Balancer
![Page 15: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/15.jpg)
Breaking The Bank
Availability Zone CAvailability Zone BAvailability Zone A
MongoDB1 MongoDB2 MongoDB3
Node.js Node.js Node.js
Elastic Load Balancer
ELB ($20/month):3 Node.js servers: 3 MongoDB servers:
t2.medium: 2 CPU/ 4GB RAM
$ 20$120$120
$260/month
![Page 16: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/16.jpg)
But How Much Is That… really?
Availability Zone CAvailability Zone BAvailability Zone A
MongoDB3
t2.medium: 2 CPU/ 4GB RAM
MongoDB1 MongoDB2 MongoDB3
Node.js Node.js Node.js
Elastic Load Balancer
500 - 1000 requests per minute
![Page 17: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/17.jpg)
EuropeUnited StatesChina
Scaling Even More...
MongoDB1MongoDB1
MongoDB1
MongoDB1MongoDB2
MongoDB2
MongoDB1MongoDB3
MongoDB3MongoDB1 MongoDB2 MongoDB3
Node.js Node.js Node.js
Elastic Load Balancer
Node.js Node.js
![Page 18: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/18.jpg)
EuropeUnited StatesChina
Scaling Even More...
MongoDB1MongoDB1
MongoDB1MongoDB2
MongoDB1MongoDB3
MongoDB1 MongoDB2 MongoDB3
Node.js
Node.js
Node.js
Elastic Load Balancer
![Page 19: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/19.jpg)
EuropeUnited StatesChina
Scaling Even More...
MongoDB1MongoDB1
MongoDB1
MongoDB1MongoDB2
MongoDB2
MongoDB1MongoDB3
MongoDB3
CDN
MongoDB1 MongoDB2 MongoDB3
Node.js Node.js Node.js
Elastic Load Balancer
![Page 20: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/20.jpg)
EuropeUnited StatesChina
Scaling Even More...
MongoDB1MongoDB1
MongoDB1MongoDB2
MongoDB1MongoDB3
Elasticsearch
Elasticsearch
Elasticsearch
MongoDB1 MongoDB2 MongoDB3
Node.js Node.js Node.js
Elastic Load Balancer
![Page 21: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/21.jpg)
Monitoring
CPU utilization - percentage of time CPU spends doing workCPU load - measure of computational work averaged over timeMemory utilization - percentage of memory allocatedDisk space - amount of disk space allocated vs. availableNetwork throughput - amount of traffic (in bytes)
CPU Wait - indicates time spent by the CPU waiting for resources to come availableCPU Steal - indicates time not available to the CPU due to the underlying host
![Page 22: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/22.jpg)
Monitoring
![Page 23: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/23.jpg)
Monitoring
![Page 24: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/24.jpg)
• Know your goal (MVP or HA)• Monitoring drives direction• Load-test all the things• Learn to forecast expenses
Take-aways
![Page 25: No More Mr. Nice Guy The MEAN Stack](https://reader035.fdocuments.in/reader035/viewer/2022062306/587f28cf1a28ab121d8b48e9/html5/thumbnails/25.jpg)
Resources
Links:• http://www.mean.io• https://angularjs.org/• http://expressjs.com/• https://www.mongodb
.org/• http://aws.amazon.co
m/• http://kkovacs.eu/cas
sandra-vs-mongodb-vs-couchdb-vs-redis
Will Button @wfbuttonhttp://willbutton.co
Don’t be jealous that I was at IteratePhx chatting with Will Button all day.