简体   繁体   中英

Speed of PubSub and gRPC PHP

We are experimenting with PubSub as a job queue and running our experiments from instances in the Google Cloud.

The problem we are currently facing is that making a connection and creating a job in PubSub takes around 300ms-700ms. We are running PHP, so on every incoming request, unfortunately, a new connection to PubSub needs to be made (at least for the front-end facing code). Is this an expected speed of the PubSub service, or are we maybe doing something wrong?

Another question is about gRPC for PubSub, this looks promising, but I can't seem to find any documentation or example code to start experimenting with this in a PHP environment. The only examples I found seem to work from AppEngine, which uses classes that are not available outside of AppEngine, as it seems.

I hope in both cases, I am missing something, I really would like to use PubSub.

Update: I partly solved the problem by setting a cache on the client. But it is still 200ms-500ms

You can now use PubSub + gRPC with the Google Cloud PHP PubSub SDK ( composer require google/cloud-pubsub ). See the official documentation for more info.

If you do use gRPC, be sure to also install the protobuf extension rather than using the native PHP implementation. Without the extension, gRPC is actually slower than REST. To install the protobuf extension:

pecl install protobuf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM