In Ubuntu, DNS is not cached.
So if my program use a lot of DNS queries and it will be plainful.
I knew in RHEL, they have nscd installed by default, so in Ubuntu, if I want to use the server as a production server, should I always install nscd?
DNS caching will depend on what DNS server you're pointing your Ubuntu server at (e.g., /etc/resolv.conf). That DNS server is likely configured to cache.
You can run your own caching name server on the Ubuntu box itself. You'll get more control over how it works in that case. If the caching name server is running locally, you may also save some network roundtrip time. But it's not obvious this configuration will be significantly better than relying on your service provider's DNS server.
It depends if your server nesds to resolve names or not.
Install it, and configure it to log everything, then start it - if it's not doing anything switch it off.