Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrency #85

Closed
rubenv opened this issue Feb 27, 2015 · 7 comments

Comments

Projects
None yet
6 participants
@rubenv
Copy link

commented Feb 27, 2015

How does grpc handle concurrency? Can I use a client from different threads in parallel?

@iamqizhao

This comment has been minimized.

Copy link
Contributor

commented Feb 27, 2015

On Fri, Feb 27, 2015 at 9:40 AM, Ruben Vermeersch notifications@github.com
wrote:

How does grpc handle concurrency? Can I use a client from different
threads in parallel?

On client, if you want to perform multiple rpc in parallel, you should
spawn multiple goroutines to do that since the rpc is synchronous/blocking.


Reply to this email directly or view it on GitHub
#85.

@jpfuentes2

This comment has been minimized.

Copy link

commented Feb 27, 2015

since the rpc is synchronous/blocking

That's what I got from looking at the route_guide example: the server's end points access a slice without locks. Is this considered quasi similar to an actor model? Is there documentation about this fact (I might have missed it)?

@iamqizhao

This comment has been minimized.

Copy link
Contributor

commented Feb 27, 2015

On Fri, Feb 27, 2015 at 11:27 AM, Jacques Fuentes notifications@github.com
wrote:

since the rpc is synchronous/blocking

That's what I got from looking at the route_guide example: the server's
end points access a slice without locks. Is this considered quasi similar
to an actor model? Is there documentation about this fact (I might have
missed it)?

To be clear, I was talking about client side. On the server side, each rpc
still has its own goroutine but the concurrency is model is different --
the goroutine is spawned by grpc internals instead of applications.

Were you talking about "savedFeatures" slice? There is no lock for that
because it is read-only once it is initialized (in grpc.NewServer).


Reply to this email directly or view it on GitHub
#85 (comment).

@jpfuentes2

This comment has been minimized.

Copy link

commented Feb 27, 2015

There is no lock for that because it is read-only once it is initialized

Got it, thanks.

@iamqizhao iamqizhao closed this Feb 27, 2015

@trevorgray

This comment has been minimized.

Copy link

commented Oct 17, 2015

I also wasn't able to find this documented anywhere but this issue. Would you be able to add this to the godoc documentation to make it more clear that it's safe to call a client from multiple go routines concurrently?

@timbunce

This comment has been minimized.

Copy link

commented Jun 30, 2017

Trying to summarize for myself...

@rubenv asks:

Can I use a client from different threads in parallel?

@iamqizhao replies:

On client, if you want to perform multiple rpc in parallel, you should spawn multiple goroutines to do that since the rpc is synchronous/blocking

That's helpful, thanks, but doesn't quite clarify if a single client object can be used by all those "multiple goroutines". It sounds like the answer is yes. This example suggests the same. Is that right?

However, a stream can't be shared.

@trevorgray, these kinds of concurrency topics are apparently still not documented, per #682.

@dfawley

This comment has been minimized.

Copy link
Contributor

commented Jul 5, 2017

That's helpful, thanks, but doesn't quite clarify if a single client object can be used by all those "multiple goroutines". It sounds like the answer is yes. This example suggests the same. Is that right?

However, a stream can't be shared.

That all sounds right to me.

@trevorgray, these kinds of concurrency topics are apparently still not documented, per #682.

Documentation is a well-known deficiency that I hope to address sometime this quarter.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 26, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.