We've requirement to deploy rails application using single front-finish server(Apache),two back-finish server(Passenger) and 2 database-server.what would be the configuration? does it effect to alter in rails application code base?

You should use Capistrano to deploy to multiple servers simultaneously. If you would like more specific configuration help please request a number of specific questions.