简体   繁体   English

GCP:在哪里安排写入BigQuery的PubSub订阅者

[英]GCP: Where to schedule PubSub subscriber which writes to BigQuery

I need to write to BigQuery from PubSub in Python. 我需要从Python中的PubSub写入BigQuery。 I tested some async subscriber code and it works fine. 我测试了一些异步订阅者代码,并且工作正常。 But this needs to run continuously and I am not 100% sure where to schedule this. 但这需要连续运行,我不确定100%在哪里安排。 I have been using Cloud Composer (Airflow) but it doesn't look like an ideal fit and it looks like Dataflow is the one recommended by GCP? 我一直在使用Cloud Composer(Airflow),但看起来并不理想,Dataflow是GCP推荐的一种? Is that correct? 那是对的吗?

Or is there a way to run this from Cloud Composer reliably? 还是有办法从Cloud Composer可靠地运行它? I think I can run it once but I want to make sure it runs again in case it fails for some reason. 我想我可以运行一次,但是我想确保它再次运行以防万一由于某种原因失败。

The two best ways to accomplish this goal would be by either using Cloud Functions or by using Cloud Dataflow . 实现此目标的两种最佳方法是使用Cloud Functions或使用Cloud Dataflow For Cloud Functions, you would set up a trigger on the Pub/Sub topic and then in your code write to BigQuery. 对于Cloud Functions,您将在Pub / Sub主题上设置触发器,然后在代码中写入BigQuery。 It would look similar to the tutorial on streaming from Cloud Storage to BigQuery , except the input would be Pub/Sub messages. 看起来与从Cloud Storage到BigQuery的流传输教程相似,只是输入内容是Pub / Sub消息。 For Dataflow, you could use one of the Google-provided, open-source templates to write Pub/Sub messages to BigQuery . 对于Dataflow,您可以使用Google提供的一种开放源代码模板将Pub / Sub消息写入BigQuery

Cloud Dataflow would probably be better suited if your throughput is high (thousands of messages per second) and consistent. 如果您的吞吐量高(每秒数千条消息)且保持一致,则Cloud Dataflow可能更适合。 If you have low or infrequent throughput, Cloud Functions would likely be a better fit. 如果您的吞吐量较低或很少,那么云功能可能更适合。 Either of these solutions would run constantly and write the messages to BigQuery when available. 这些解决方案均可以持续运行,并在可用时将消息写入BigQuery。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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