When to use goroutines #programming #coderlife

preview_player
Показать описание
In this short i talk about how to use goroutines and how they dont guarantee any performances. Go routines are not parallelism #golang #go
Рекомендации по теме
Комментарии
Автор

concurrency and parallelism can achieve the same goal, but its situational on if your “background job” is thread blocking or not, that’s the only meaningful distinction at this level. It’s not simply just if you need to run background jobs, they both can

techno
Автор

I mostly think of it as: "I want a goroutine when i don't want something to block my main execution" or it is very usefull when you have to start stuff that you need to wait for but you want to start all of them at once, like multiple http calls in a single request or multiple queries that i know take some moderate amount of time. But people tend to over optimize and forget that goroutine have a cost and are not free. Once i saw someone doing goroutines to have faster responses from 3 queries that took nanoseconds ( fetches on PK's from static tables with low row counts ) and it took more to start the goroutines then to finish all 3 requests.... People need to spot hyperoptimizing stuff

eptic-c
Автор

What did he mean by process request and backend cleanup?

driyagon
welcome to shbcf.ru