Have you considered how it was done historically?
In most games that work similar to the type of game you seem to be developing (I've thinking Travian, Goodgame Empire and another one that got me so salty I can't be bothered trying to remember the name (but I remember that it had a shitty marketing technique)) combat is just a slow movement of troops, instant maths to resolve the combat and then a slow returning of troops. This is not how combat works! This is not how you would take a base historically! Conquering a fortified position is a very significant and time consuming task. Fortifications are much harder nuts to crack than game developers either realize or care to properly emulate.
My suggestion is going to make attacking another player a much larger investment of time and resources and it's also going to make defence more costly. However, it will also open up a whole lot more options for both sides. So much so that it might become a different game than you had originally intended.
Assuming that the defenders have any kind of wall protecting their base, then instead of instantly resolving combat when the attackers arrive, the attackers should set up camp around their target. In other words, they should besiege them.
The siege can be strengthened by adding more troops to it. This is one way to work together with your allies. However, this goes for the defender's allies as well who can send a force to relieve them.
Supply issues will be the main driving factor
While the siege is in place the defender should be unable to gather resources as their access to the surrounding lands are cut off. Instead they start eating into their food and water* stores until they are depleted as well as burning all their wood, coal and oil for heat, light and cooking. Once the food has run out the castle surrenders unconditionally.
Of course, the attackers also need to eat and feeding an army away from their home is no small task. Their choices for this is...
1. Supply caravans. This will be the main way to resupply your troops. You can provide it yourself, rely on an ally to provide it or negotiate for it with third parties (perhaps on the threat of besieging them next if they don't).
2. Scavenge. This will only be able to provide a little bit of food. It's not enough for a large force for a long time, but it works as a stop gap if you're having trouble with supply lines.
3. Raiding. This is more effective than scavenging, but it causes significant collateral damage to the surrounding land, which is bad if you intend to conquer the land for yourself. It also puts a limit to how much you can raid. Raiding can however be an end goal in and of itself as you weaken your enemy and then leave without actually trying to take their base.
Both scavenging and raiding the countryside requires the besieger to disperse some of their troops for some time, which is a perfect opportunity for the defender and their allies to sally out of the base to strike at the besieger's main camp or for allies outside the siege to pick off these smaller scavenging/raiding parties.
Supply caravans might seem like the superior choice now, and they should be, but you might want to make them vulnerable to interception in some way.
Lots of choices!
You now have a siege in progress. This gives both sides a number of options to consider.
1. Wait... Hope that the attacker will leave or that an ally will come and relieve you. If nothing happens your base's inhabitants will begin to starve when supplies run out and eventually surrender unconditionally. However, it takes two to have a siege and your besieger's troops are locked in their position unless they want to abandon the siege.
2. Sallying out is an option for the confident defender faced with an attacker who tries to bite off more than they can chew. End the siege early by defeating the besiegers while they are at their weakest.
1. Wait... As long as you have a steady stream of supplies to keep your troops from starving and disbanding you can win by just waiting out the enemy to consume theirs.
2. Raid the countryside to spite the enemy into attacking you or just to weaken them for future engagements.
3. Assail the walls to try to take the castle with overwhelming force. This is very difficult as a well-built fortification can be defended by a handful of men in the face of a many times larger foe.
Negotiate! You want to take the castle for yourself? Save yourself time and resources by offering the defender safe passage for their troops to leave. Your attacker wants resources? Offer to pay them off to break the siege. Maybe you and your allies can make an offer juicy enough that one besieger abandons his allies who then become easy pickings.
Maybe the besieger has some other purpose with the siege? Just about anything can be negotiated! Just make sure that there's no penalties for breaking a siege and going home or at least that they are much lower than the penalties for continuing the siege. You don't have to develop for all the possible outcomes from negotiation. Let the players resolve matters by sending each other messages and they will find ways to achieve the outcome within the game mechanics.
The siege mechanics should open up a lot of strategical options as well. Consider that the A-Alliance wants to conquer the B-Base of the C-Coalition. A-A will send their main forces to B-B. But they also send smaller forces to besiege some nearby bases. These forces aren't large enough to take those bases, but they are large enough to prevent the enemies in those bases from sallying out and coming to the aid of B-B. C-C has the option of sending forces from further away to relieve B-B or they could start dislodging the enemies around the surrounding bases to free up more troops and supply sources in preparation to finally relieve B-B. However, doing so may cause them to arrive too late. Choices are fun. Making the right choice is a challenge in and of itself and it turns warfare into more than just a contest of who can amass the most troops and throw them at sleeping players.**
Here's the crux of the matter. This is the part which the question focused on. This suggestion has so far lessened the problem by reducing the amount of combat by instead implementing a war on resources and time. This makes it more historically accurate, but combat is still an important aspect of the game and perhaps the most fun part for some players. How we deal with it depends how you intend for combat to work in your game. I will explore those options further down, but first we deal with the issue of players being overwhelmed by enemies they are not prepared for.
The siege mechanics deal with this by forcing an attacking enemy to first besiege the base. However, this is pointless if the enemy can just attack and overwhelm the defender right away. Sieges take time. Therefore, after arriving there should be a cooldown before the besiegers can attack. This time represents the time it takes to build ladders and siege engines*** and preparing your forces for an attack. The cooldown should be longer the better fortified their enemy is and the timer should reset after every attempted attack. The defender might have a good view of the surrounding area and thus be able to tell how long it will take before their besiegers' cooldowns finish. Though the besieger doesn't have to attack as soon as the cooldown runs out. They can take their merry time just sitting about if they wish.
Also remember to give the defender a significant advantage! Attacking a fortified base is difficult and costly, which is why sieges were the overwhelmingly most common form of warfare historically (if you have a fortress then why not use it, you know?). This needs to be true in your game too or the whole siege mechanic becomes pointless. If the attackers doesn't need to commit a lot of forces to win a siege without waiting it out then it becomes too hard to defend against even an alliance of equal strength. You want your players to be able to stand a decent chance of defending against a superior enemy alliance or whomever attacks first will simply steamroll their enemies.
Instantly resolved combat
If you want the Travian style battles which are instantly resolved mathematically rather than having the players play the actual combat, then we're done here. The siege mechanics and attack cooldowns will give the defender and their allies plenty of time to react to the attacker. You don't need to be present for the actual battle, you just need to know ahead of time when a battle might happen so that you can prepare in time.
The movement of enemy troops and the attack cooldown should give enough time to make you aware of the threat unless you stay offline for a long period of time, like over 24 hours. As long as you check in once a day that should be enough, so that an entire alliance doesn't just decide to gang up on you while you're sleeping so that you wake up to having lost your strongest castle without any warning.**
If you want combat that requires the players to move pieces on a field to actually play out the combat, then there's no way around it, your players must negotiate for a time to play out the combat. You should build a system around it and you may have to do some time jumping to achieve it.
For example, if the attacker suggests one time to fight and the defender suggests a later time then you shouldn't allow allies of the defender coming to relieve the siege in between those two times to take part in the combat, as that would be unfair to the attacker who wanted to fight before the arrival of more enemies. If the relieving ally tries to negotiate for combat with the attacker upon arriving, then that combat should not be allowed to be held before the combat which the attacker tries to negotiate a time for with the defender, because that would screw up the timeline and make the attacker fight with a weakened force in a battle that was supposed to take place before he was weakened.
In other words: the timeline of the battles, and thus the order in which they should be fought, should be determined by the initial time suggested even if that did not become the agreed upon time. Which players that can participate in the battle should also be determined by who was at the siege at the initially suggested time. Cooldown effects should only take the initially suggested time into account. Name the battles using the in-game time of the initially suggested time to make it more clear to the players.
If the sides have trouble organizing a time on which to fight and there are multiple fights being queued then that could lead to a series of fights which -according to in-game time- only takes a few days end up spanning a whole week or two IRL. This is fine though. By implementing the suggested siege mechanics you've already determined that your game will be the long con kind of game where things elapse more slow and steady.
After a battle the attacking or relieving force should get the option of retreating back home and thus cancelling their participation in upcoming battles. Or course, the defenders who are trapped in their base don't get a choice. If any player doesn't show up for battle at the predetermined time then their forces will be played by an AI. If no one shows up then the battle will be auto-resolved mathematically. This is so that upcoming battles can continue as expected. To prevent decimation of anyone's forces because they weren't there to cancel their upcoming battles you could implement a moral mechanic which causes troops to automatically retreat back home if they are poorly supplied and/or losing too many battles.
If you implement the siege mechanic as suggested then you are probably going to end up with a game that works very differently than you had originally imagined. The overarching strategical part of the game has to become more slow paced for the siege mechanic to work and the players needs to put more consideration into their strategical actions. This will appeal to some players and it will turn other players off, just like with any major design decision. However, the important part of the question -how to prevent players who are sleeping or otherwise pre-occupied with real life from being curb-stomped by alliances of opportunistic hyenas**- has been solved. Because you now have a game where players are fine if they just check in once a day or so due to the slower pace.
*Water is an essential resource which is consumed in large amounts. If your base doesn't have a well then it will need to store a massive amount of water. Normally a base would have a well, but if you choose to build your base on an easily defensible mountain top then it might not be possible to find water.
**Yes, I'm salty.
***Unlike what most strategy games suggest, you don't actually drag siege towers and trebuchets with you from home. You build them at the siege with locally sourced lumber.