I am new to web development and server set up. I am looking for some advice or a link to a tutorial on setting up a production system up. Right now, I have a server (Ubuntu, Apache, MongoDB, and PHP). It receives a request, PHP queries Mongo, and PHP sends out the requested data. How do I make that work with more servers? I've read that you can make a cluster of a primary and two slave nodes which work as separate servers running Mongo, but do those also run PHP? Or is the primary the only one running the PHP?
I have read some docs on Mongo site and a video of someone from 10gen going through it, but they are geared towards people that seem to already understand this stuff, I have no idea and need to start from a beginning stage.
If anyone can help me understand where PHP (Acting as my API) lives in these clusters, that would be greatly appreciated! Thanks in advance for any help!
Answer
When you scale out, you generally break out your components. You end up with something like this (these are not standard names, nor do you have to do this, but this is common):
- Application Server(s) (Linux, Apache, PHP)
- Database Servers(s) (Linux, MongoDB)
How many you need of each will depend on your application needs. On the MongoDB side of things, for production you will want to run at least a replica set. This would constitute one primary, one secondary and an arbiter as a minimum (see the docs, but as a quick guideline, the primary and secondary should be identical and are generally dedicated hosts, the arbiter has no data and is lightweight, could be run on a shared host).
The applications server will take requests from clients, be they human or some other app calling your application. The application will use the PHP driver to communicate with the MongoDB replica set over the network (rather than locally, which is what you have probably been doing up until now).
Eventually, if you continue to grow, you may need to expand to a sharded MongoDB set up. From a PHP perspective, the only difference will be that you talk to a mongos process instead of directly to the replica sets. That sounds like it is down the road for you in this case though, so be aware of it but it should not be necessary in the immediate future.
No comments:
Post a Comment