I have been suffering this same problem intermittently through various OSs for a number of years.
I am now convinced that he problem is not with the OS.
I have an iMac with a wired connection to my router, which in turn has a wired connection to my AV amp and my TV. The AV amp and TV are both Sony devices, but this is of no relevance as I had exactly the same issue with a previous Denon AV amp and the same family of routers.
My desire is to play my iTunes through my very nice home entertainment system controlled via the Sony AV amp.
When I turn on the computer, the Airplay doesn't show up if the AV amp isn't on. That's obvious really, why would it?
If I turn on the AV amp, then it still doesn't show up. Now, this is a little strange.
If I turn on the AV amp first, and then the iMac, then Airplay appears and it works fine, until I (or usually one of the children!) turns the AV amp off again while I am using it. Now, I can't get it to come back on again until I unplug the AV amp from the wall and reboot it completely.
All this is a bit long winded, agreed, but the point I am trying to get to is that this is almost certainly an IP issue between the AV amp, the router and the iMac, and unfortunately my skills with IP addresses aren't good enough to resolve this, but my original point is that I don't think the problem is with the OS.
One thing worth noting though, is that when I launch my iMac into Windows 10 in Bootcamp, the connection is much better, more user-friendly and much less likely to time out or drop out after a period of time. So, despite my love of Apple OS, it seems that Windows networking is a load better than Apple's.
Just to add, I have also tried setting the IP address on the AV amp to be fixed as well as dynamic on my network, and it still only works intermittently.
:-(