I hope you can understand and know the powerful of meteor.
sort by the increment of complexity and number of client that server can afford to handle
firstly I gonna show you simple architecture of server.
Your application has 2 separate parts: application logic and database. In this case, I use mongodb because it is the default database of meteor.
The picture in the left hand side is the simplest architecture working on 1 machine. To extend this architecture I split into 2 different servers. 1 for application logic. another for mongodb
Now I gonna show you how scale your application logics.
first step I add many application logics as I want to the previous architectures. The problem is how to make it work together.
then I add a NGNIX server as a proxy, caching server, load balancer to receive client connections and push it to application logics.
As you see there is only one mongodb receiving connections from many application logics. it will be a bottleneck of your system. Then I attempt to scale mongodb.
I apply replication to increase performance of reading operations. Because databases in primary and secondary are the same. Application logics can read from one of them.
I can add many secondary as I want, but tow is the minimum number.
After using replication. If you still meet the performance problem. I suggest that you should consider next architecture.
make use of sharding to increate writethrough of your system. In every shard, I apply replication.
Your system will be stronger, But I have never seen any website website using this feature. Maybe, they don't have enough users to deploy this.
So far, I have provided your simple theory of server architecture.
Next, I gonna show you how to do it in real.
I choose amazon web server as a server provider, I need 5 server to deploy application architectures. 4 servers for mongoldb replications (1 primary + 3 secondaries). And my server can handle more than 5000 concurrent users.
Meteor - up is a powerful open source library which helps you to deploy your application.
show this website
first step: I must create mup.json file following the syntax of MUP
I gonna show you mup.json file of our real system.
in the first part we add address of 5 servers
in the second part I add address of all database.
how to apply cluster. it is so easy
create 4 server instance —> install your mongoldb - > go to every server and run this command
dbpath points to place to save data files.
replset requires name of your replicaset
you need auth to enable security mode
keyfile help those server securely communicate
mup setup: install mongodb, nodejs, phantom….
mup deploy: bunle your app -> send it to all your server —> then run
mup logs: the see logs of your server
mup recofigure: when you have changed configuration and apply to your system