When writing an application to support scalability, how do I decide whether to support it using technologies such as EJBs and distribute the application among multiple machines, or to write the software without using such technologies and just replicate it in multiple machines?
Are there any good resources (books/articles) that explain this?
Scalability is more of an Architecture capability. Technologies and tools just realize this capability.
If you define your architecture inherently scalable, then you can retrofit any technologies to support the architecture. You can find examples out there which have scaled very well for large user base in almost all tech stacks ( be it PHP, .NET, Java, COBOL, RoR etc).
Since these days, it is cheap and easy to deploy on the cloud, design your architecture keeping in mind Share Nothing architectural concepts. You can easily scale on demand for any large userbase.
Coming to the specific technology which you have mentioned, EJB – it is an middleware technology and it comes with a baggage – Java EE Application Server (or Tomcat with some plumbing). The point is EJB solutions are not lightweight and are advised for specific use cases like – remotability, transactions etc etc. Plus the cost of developing standards based solutions is little on higher side then just using Open source stack.
From scalability point of view, standards based solutions i.e. EJB, JPA etc are also Cloud enabled and support Cloud scalability i.e. replicating and sharing. Check this link.
With or without standards – what matter is the Application architecture which can scale.