Rendering Blender animations on a server: more RAM or faster CPU or both? For my project Blender is used to take .STL files, and render a GIF animation (first - several jpg are created and then merged together in an animation).
This is all done using a server cron (daily). Obviously, I can't use GPU that can speed up things a lot.

I'm thinking about moving this blender-specific task out of the main server (so it won't make CPU nearly 100% while blender is working), so the application will work independently. 

I'm using DigitalOcean for hosting, and it has standard droplets (like, containers or virtual machines) and optimized. Optimized has better CPUs (they are faster). But for the same price Standard droplet has more RAM.

So the question is: what is better for blender to work faster - to have more RAM with ordinary 2 or 4 vCPU (they have slower speed) and 4 or 8 Gb RAM, or better speed but for 2 vCPU and perhaps less amount of RAM (4 Gb)?

And how to optimize the server for blender speed? Any tips that can be applied in my server-related use case?
Note: I assumed that you are just running a single blender render instance on the system at the same time.

Depends on the complexity of you scenes. If these are rather simple scenes than not that much of RAM is needed. Adding more RAM will then not increase performance. More RAM will only increase performance when the machine is going to swap on disk.

If the complexity of the scenes are known, then the Amount of RAM can be received from blender easy (see top bar). Add some percentage slack and you will be fine. 

If you still want to render more quick, then just add more CPU's. Blender is optimized to scale very well by just adding more CPU. It does not have noticeable overhead on memory.

Another way to increase performance is to optimize your scenes. There are a lot of topics and tutorials on area's where you can win speed.

So to answer short: Find RAM needed for the complexity of your scenes. Then just add more CPU's.