What is the proper way to set up Drupal 7 on load balanced servers so that CSS and JS files are in sync? We're moving our website to new Cloud Load Balanced servers on Rackspace. It's all a bit of a new experience for us, we've ironed out most of the issues, apart from one.

We've set up the new servers to lsync from Server A to Server B (Server A is master).

From time to time we see css/js files 404. We can guess what's wrong, it's file syncing not happening fast enough between servers, and when a cache clear occurs on Server A, such as a cron run, then Server B is requesting the old CSS/JS files, and that request may go to Server A.

What is the proper way to set up Drupal 7 on load balanced servers so that CSS and JS files are in sync and don't cause 404?
Drupal's core aggregation does not work on a cluster because it creates the aggregates  during the page rendering. Once the page is stored into the cache another server of the pool will read from the cache so it will not render the page again meaning that the CSS or JS aggregation will not be done locally.

To solve this problem, I created a NFS share between the servers just for the "css" and "js" folders. It was running ok for a while but under heavy load Drupal was sometimes generating empty files (2 servers creating the file at the same time). So even keeping in sync the servers is clearly not a solution.

But just as Beebee said, you can use the Advanced CSS/JS Aggregation module. This one is clever enough to be able to rebuild an aggregate just from the URL, because it stores in the database a mapping of the files that are part of the aggregate.

Advagg is also able to handle groups of aggregated files. This can reduce your bandwidth usage if your visitors navigate across different pages because the common files can be merged into a separate aggregate and the delta files merged into another aggregate.