This was originally a response I wrote on a forum, but I thought it might be useful enough to create a blog entry for it. I've edited it slightly here.
Every single upgrade is beneficial and as countless people have said over and over, ultimately you want to max out everything before moving onto the next Town Hall level. However, at each Town Hall level it takes progressively more and more time to upgrade everything (many months at the highest levels), so what do you upgrade first?
Walls are becoming slightly less important due to the popularity of attacks with air units and/or hog riders (although they are still important and certainly a minimum level of walls is needed), but obviously every defensive upgrade improves your chances of winning (or at least slowing down your opponent) and keeping those hard-earned resources. That being said, however, it's harder to earn those hard-earned resources without a strong army. Here is my own personal philosophy regarding upgrades:
- Regardless of the order, eventually everything will be upgraded to the maximum level for that Town Hall (including walls). I've maxed out every Town Hall since TH4 (I am TH8 now, 6 upgrades and 90 walls away from maxing it and upgrading to TH9).
- Defense, offense and resources are all important. Generally I end up splitting my builders among all three of those tasks. When I had 3 builders it was one builder for defense, one for offense and one for resources. Now that I have 5 builders I generally use 2 offense, 2 defense and 1 resource.
- The laboratory is always, always first. Why? Upgrading your troops is not only hugely important for attacking, it takes SO much time to upgrade all of the troop levels available. And you can't begin that task until the laboratory is finished, so get it started as quickly as you can!
- Build any new army camps/barracks that you receive, if any. A brand-new army camp is 20 extra spaces, while even the most expensive upgrade only gives 5.
- Next upgrade your army camps. Always upgrade the smallest one(s) first, because every upgrade is 5 spaces and the smaller the camp, the cheaper/faster it is to get that 5 extra spaces. Army camps are more important than barracks, unless you really think you need the next troop unlocked for your attacks. If you want to try giant/healer but don't have healers yet, upgrading one barracks is probably a reasonable idea.
- Once the army camps (and possibly one barracks) are done, next up is the spell factory.
- Finally the rest of the barracks/dark barracks. It's tough to have more than one barracks upgrading at once as even one slows down your army training considerably, but when I was upgrading them to level 10 I actually just decided to take a little break from attacking and upgraded them all at once (figuring that 6 days of no attacking was better than 24 of painfully slow army training).
- Last (but not least), keep that laboratory busy! I actually prioritize lab upgrades over building upgrades; if my lab was finishing up at the same time as my offensive builder, I'd start the next troop upgrade first and then farm up elixir for the builder even if it meant the builder was idle for a few hours.
- Get your new walls built and upgrade them at least to level 3 or 4 (it's still relatively cheap at that stage).
- Get any new defensive structures built as quickly as possible. I also tend to upgrade them right away through their cheap-and-quick levels (anything under a day, typically). Then I leave them and move onto the next step.
- Continue to upgrade your new walls until they are the same level as the rest, a few at a time between upgrades.
- Upgrade that splash damage! Usually I go mortars first and then wizard towers, but either order is fine.
- Now go back and get those new defenses to the same level as everything else. Generally I just tended to do whatever was cheapest/quickest first, then the next cheapest/quickest, etc.
- Once that's done, then you can start on the new levels. Again, cheapest and quickest isn't a bad policy.
- For the last upgrade of all of your walls, I found what I thought was a pretty decent strategy. Once all of your defenses are one level away from max, divide the number of wall upgrades by the number of defensive structures you have to upgrade (for me at TH8 it was 225 / 22, or roughly 10). Then, upgrade that many walls before you upgrade the next defense. By the time all of your defenses are done, your walls will be too.
- Get any new buildings built. ESPECIALLY get that Dark Elixir Storage built at TH7, and any new DE drills at TH8+.
- Storage upgrades are cheap and quick (except for the DE storage) so get any new storages upgraded reasonably quickly. The only exception to this, in my opinion, is the second storages at TH3: that can typically wait until TH5. Some would argue that you don't really need the third storage at TH8, but I built it right away and was very happy that I did. The argument goes that it's easier to defend 2 storages than 3, but my personal experience is that opponents can only effectively attack from two sides: any more than that and their troops are too spread out to penetrate defenses. With two storages your opponent is reasonably likely to get both, while with 3 storages (spread out) I very rarely lost all 3 (unless I was being attacked by a clearly superior opponent). That would generally save me 60k gold or elixir.
- Get collectors upgraded. These take forever (by comparison at the levels they are received) but are really cheap. I generally used these just to keep builders busy when I didn't have much in the way of resources to spend. Obviously the DE drill is the exception, but by the time you get that you should be done with all of the other collectors (until TH10).