On Tue, Aug 14, 2018 at 2:55 AM ranjith <[email protected]> wrote:

> I have a gRPC service running fine on a server. I have limited amount of
> servers so what I want to do is run this service on the same server but on
> different ports (basically faking the number of grpc servers). The service
> has a single rpc which sends data every 1 second.
>
> I am running this service on 100 different ports staring from 50000 to
> 50100. Now there are 100 different clients making requests to their
> corresponding server. What I noticed is the data is not sent by these
> servers every 1 second.
>
>
> Example:
>
> Servers are running on localhost:50000, localhost:50001, localhost:50002
> .... localhost:50100
>
>
>
>
> class OpenConfigServicer(plugin_pb2_grpc.OpenConfigServicer):
>
>         def dataSubscribe(self, request, context):
>             # this rpc yields data every 1s
>
>
>
> def serve():
>         servers = []
>         for i in range(50000, 50101):
>             server = grpc.server(futures.ThreadPoolExecutor(max_workers=1))
>             servers.append(server)
>         i = 50000
>         for server in servers:
>             plugin_pb2_grpc.add_OpenConfigServicer_to_server(
>                 OpenConfigServicer(), server)
>             server.add_insecure_port('[::]:' + str(i))
>             server.start()
>             i += 1
>
>
> Can someone tell me if we can optimize this
>

Probably not that important: why have 101 OpenConfigServicer instances
rather than one that is shared among all your grpc.Server instances?

Probably more important: why have 101 grpc.Server instances each serving on
one port rather than one serving on 101 ports? Why don't you construct one
server outside your loop and only call add_insecure_port on that one
grpc.Server instance inside the loop?
-Nathaniel

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CAEOYnASiUtat2X43c_HAnK-x86%2BNNPf6Nr079gdsQQBFO%3DQTnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to