Which direction should I go? What should I taking into consideration?
I cannot tell you which direction to go because that will require careful consideration of your problem domain, end users and some testing. However, I can help you figure out what to take into consideration.
Your application servers are fixed. You might have 2, 3 or even 4, but whatever the number, you have a certain number. You can scale horizontally by adding servers, but there is a direct linear cost to that.
On the other hand, you have N clients. Each user who visits your site has their own CPU and memory. In terms of executing your code, that is free CPU and memory :) Hard to pass that up.
Your clients also provide a level of isolation. The work of one client does not impact the work of another in regard to client-side code. If everything executed on the server, one HTTP request going awry can bog down a server that is shared by many users.
Client machines vary. There are users running Safari on a Mac, Chrome on a Windows 7 64-bit machine with 8 GB of RAM and users running IE8 on Windows XP 32-bit. You can't predict how your client-side code will perform because there are major factors outside of your control. Your servers on the other hand, are very much under your control. You can monitor their performance and scale them up or down as needed to balance performance and costs.
Calculating something on the server may be faster, but if you end up having to push a large data set down to the client over the Internet, not only is there a latency component to that, but you are likely billed by bandwidth usage. Therefore, if you have a cheap calculation that results in a large data set (let's say an array of all even numbers up to 1 million), let the client do it.
Your servers are under your control and therefore you can monitor their performance. If requests to a specific page are returning results to the client after 5 seconds, it is easier to detect and debug that on your servers. There are tools and mechanisms to monitor client-side performance, but the trade-offs and complexities are usually higher (like how do you report the data back to a central place and report on it?), like:
- How do you report the data back to a central place?
- Performance hit of executing additional code
- For clients where the performance is extremely bad, you may not even get the measurements, which biases your metrics because the worst performance is what you need to know the most about.
Server-side performance can be monitored via log files.