What is a fair, market-rate deal for a first-time technical author writing about a popular subject? You're going to be shocked and dismayed by the offer they give you. Let's get that out of the way now. This is the model: they'll tell you to not do it for the money, in exactly those words, prior to explaining to you terms which imply that they're not doing it for ~92.5% of the money. You will likely be offered someth…
Expect $0 to $3k from a really shitty publisher who is probably just going to waste your time, or a serious publisher who believes you'll waste the publisher's time, or both.
$3k to $6k from a publisher who has some clue, but the topic is extremely niche. ("Pentesting South African Wifi Networks with Monads")
$6k to $12k from a publisher with some clue for a book that will sell fairly well to a big niche developer audience - something like a developer guide to Android or iOS.
$12k to $25k for super-popular consumer tech books for mainstream topics like macOS, iOS, and so on.
Royalty rates are 8% to 12%, maybe 15% for someone with a track record. (8% and $5k is standard for mid-list unproven fiction. Tech rates can be higher.)
Watch out for comedy royalty rates on ebooks. (15% on a downloadable file? 50% or GTFO.)
True: advances don't usually earn out. And if you write more than one book the unrecouped advances get added together, so you will never, ever, earn out, unless a book becomes an unexpected best-seller.
Which it won't, because publishers do not promote books. There's a sell-in period aimed at store buyers before publication to get the book on physical shelves, but otherwise publishers do somewhere between exactly zero and almost zero marketing and promotion.
Bottom line: writing books on its own is largely a waste of time, unless you want to research a topic and get paid to learn it and don't mind producing a book to pay for the payment.
Writing books as shop windows for other tutorial content and/or consultancy can work very well.
People who know what they're talking about, can write to a deadline and make sense, and are willing to accept pocket money are incredibly rare. Publishers often trawl for new writers, and if they find someone who is all of the above and not too easy to flatter they may be willing to push the advance higher than usual to close the deal.