And when there are multiple servers (app servers and db servers), ntp should be installed both servers? and then how to sync the time each servers?
When I insert something with NOW()
sql, the time is from db server?
I assume a simple web service using Rail on this app servers.
Yes, you should always install ntp if you can on all and any servers especially production boxes. It will save you hours of pain and troubles later.
This is a quick guide to ntp setup on Linux which should give you some ideas as to how to set up, what the config options do etc.
If you only have two servers in your deployment then I'd suggest you find some 'trusted' low stratum ntp servers that you can use, and apply the same config to both servers.
Make sure you have a minimum of three upstream servers to connect to, ideally five for a robust time domain.
Once you ntp setup and running and your servers are keeping time whenever you ask for the time, it should be the correct time within a small margin of UTC. So in Ruby if you do Time.now.strftime("%Y-%m-%d %H:%M:%S")
it will return the hosts time as set/clocked by ntp.