Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question
    
You'd typically run MongoDB in a replica set (minimum three servers), and you'd typically have PHP on a separate (probably at least two, for high availability) set of servers. –  ceejayoz Nov 1 '12 at 4:09
    
Check out 12factor.net for high-level descriptions on scalability of your application. I think this can be a starting point on how to properly run your application in production. –  pkhamre Nov 1 '12 at 8:00
    
Thanks for the help! –  w3rthl3ss Nov 1 '12 at 23:43

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
    
Thanks for all the help and comments! –  w3rthl3ss Nov 1 '12 at 23:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.