On Saturday, January 7, 2017 at 3:05:28 PM UTC+8, Lazytiger wrote: > > Actually, I meet two kind of crash, “pthread_create failed" and “out of > memory”. > But it’s kind of a heisenbug, I can’t always reproduce it. >
The number of goroutines has no direct relations to “pthread_create failed". It is true that each goroutine needs minimum 2k stack size. For your original question, Golang supports millions goroutines well. Generally, the number of goroutines is not the main factor to consider in Go programming. BTW, one reason of "too many system threads" is there are many concurrent blocked disks I/Os. > 在 2017年1月7日,下午2:14,Michael Jones <[email protected] <javascript:>> 写道: > > It is difficult imagine "pthread_create failed" as the result of too many > goroutines. > > On Fri, Jan 6, 2017 at 8:11 PM, Hoping White <[email protected] > <javascript:>> wrote: > >> Hi, all >> >> I’m writing a chat server like program, and I must make a decision now. >> My business includes two kind of things: >> 1. request->response >> 2. push message >> >> One solution is like every connection has 3 goroutines: >> 1. for read request >> 2. for write response >> 3. for execute request >> >> But this kind of solution will cause too much goroutines. I have seen >> “pthread_create failed” >> already. I digged net/rpc package code, and found that, rpc only use a >> long run goroutine for >> read, and a short term routine for excuting request, and it has no push >> requirement. >> >> So there is another solution maybe >> 1 long run routine for read request >> 1 short term routine for execute request (request should be sequenced, >> how?) >> 1 short term routine for write response (response should be sequenced, >> how?) >> >> My question is, is short term routine is a better practice than long run >> ones. If so, >> how to meet the sequence requirement? >> >> Thanks >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Michael T. Jones > [email protected] <javascript:> > > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
