Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Pub/Sub adalah layanan pesan asinkron dan skalabel yang memisahkan
layanan yang menghasilkan pesan dari layanan yang memproses pesan tersebut.
Pub/Sub memungkinkan layanan berkomunikasi secara asinkron, dengan latensi yang biasanya berkisar 100 milidetik.
Pub/Sub digunakan untuk analisis streaming dan pipeline integrasi data untuk memuat dan mendistribusikan data. Middleware ini sama efektifnya dengan
middleware berorientasi pesan untuk integrasi layanan atau sebagai antrean untuk melakukan tugas secara paralel.
Pub/Sub memungkinkan Anda membuat sistem produsen dan konsumen peristiwa, yang disebut penayang dan pelanggan. Penayang berkomunikasi dengan
pelanggan secara asinkron dengan menyiarkan peristiwa, bukan dengan
remote procedure call (RPC) sinkron.
Penayang mengirimkan peristiwa ke layanan Pub/Sub, tanpa memperhatikan
cara atau waktu peristiwa ini akan diproses. Pub/Sub kemudian
mengirimkan peristiwa ke semua layanan yang bereaksi terhadap peristiwa tersebut. Dalam sistem yang berkomunikasi
melalui RPC, penayang harus menunggu pelanggan menerima data. Namun, integrasi asinkron di Pub/Sub meningkatkan fleksibilitas dan keandalan sistem secara keseluruhan.
Menyerap interaksi pengguna dan peristiwa server. Untuk menggunakan peristiwa interaksi pengguna dari aplikasi pengguna akhir atau peristiwa server dari sistem Anda, Anda dapat meneruskannya ke Pub/Sub. Kemudian, Anda dapat menggunakan
alat pemrosesan streaming, seperti Dataflow, yang mengirimkan
peristiwa ke database. Contoh database tersebut adalah
BigQuery, Bigtable, dan Cloud Storage.
Pub/Sub memungkinkan Anda mengumpulkan peristiwa dari banyak klien
secara bersamaan.
Distribusi peristiwa real-time. Peristiwa, baik mentah maupun yang telah diproses, dapat
disediakan untuk beberapa aplikasi di seluruh tim dan organisasi Anda
untuk pemrosesan real-time. Pub/Sub mendukung "bus peristiwa
perusahaan" dan pola desain aplikasi berbasis peristiwa.
Pub/Sub memungkinkan Anda berintegrasi dengan banyak sistem yang mengekspor peristiwa ke Pub/Sub.
Mereplikasi data di antara database. Pub/Sub
biasanya digunakan untuk mendistribusikan peristiwa perubahan dari database. Peristiwa ini
dapat digunakan untuk membuat tampilan status database dan histori status di
BigQuery dan sistem penyimpanan data lainnya.
Pemrosesan dan alur kerja paralel. Anda dapat mendistribusikan banyak tugas secara efisien di antara beberapa pekerja menggunakan pesan Pub/Sub untuk berkomunikasi dengan pekerja. Contoh tugas tersebut adalah
mengompresi file teks, mengirim notifikasi email, mengevaluasi model AI,
dan memformat ulang gambar.
Bus peristiwa Enterprise. Anda dapat membuat bus berbagi data real-time
di seluruh perusahaan, yang mendistribusikan peristiwa bisnis, pembaruan database,
dan peristiwa analisis di seluruh organisasi.
Streaming data dari aplikasi, layanan, atau perangkat IoT.
Misalnya, aplikasi SaaS dapat memublikasikan feed peristiwa secara real time. Atau,
sensor perumahan dapat melakukan streaming data ke Pub/Sub untuk digunakan dalam
produk Google Cloud lainnya melalui pipeline pemrosesan data.
Memuat ulang cache terdistribusi. Misalnya, aplikasi
dapat memublikasikan peristiwa pembatalan validasi untuk memperbarui ID objek yang telah
berubah.
Load balancing untuk keandalan. Misalnya, instance layanan dapat di-deploy di Compute Engine di beberapa zona, tetapi berlangganan topik yang sama. Jika layanan gagal di zona mana pun, zona lain dapat mengambil beban secara otomatis.
Membandingkan Pub/Sub dengan teknologi pesan lainnya
Pub/Sub menggabungkan skalabilitas horizontal
Apache Kafka dan
Pulsar dengan
fitur yang ditemukan di middleware pesan seperti Apache ActiveMQ dan
RabbitMQ. Contoh fitur tersebut adalah antrean pesan yang tidak terkirim dan pemfilteran.
Fitur lain yang diadopsi Pub/Sub dari middleware pesan adalah
paralelisme per pesan, bukan pesan berbasis partisi.
Pub/Sub "menyewakan" setiap pesan ke klien pelanggan, lalu
melacak apakah pesan tertentu berhasil diproses.
Sebaliknya, sistem pesan lain yang skalabel secara horizontal
menggunakan partisi untuk penskalaan horizontal. Hal ini memaksa subscriber
untuk memproses pesan di setiap partisi secara berurutan dan membatasi jumlah klien
serentak dengan jumlah partisi. Pemrosesan per pesan
memaksimalkan paralelisme aplikasi pelanggan, dan membantu memastikan
kebebasan penayang dan pelanggan.
Membandingkan komunikasi Layanan ke layanan dan layanan ke klien
Pub/Sub ditujukan untuk komunikasi layanan ke layanan, bukan
komunikasi dengan klien IoT atau pengguna akhir. Pola lain
lebih didukung oleh produk lain:
Pub/Sub memiliki banyak integrasi dengan produk Google Cloud lain untuk membuat sistem pesan
yang lengkap:
Pemrosesan streaming dan integrasi data. Didukung oleh Dataflow, termasuk template dan SQL Dataflow, yang memungkinkan pemrosesan dan integrasi data ke BigQuery dan data lake di Cloud Storage. Template Dataflow untuk memindahkan data dari Pub/Sub ke Cloud Storage, BigQuery, dan produk lainnya tersedia di UI Pub/Sub dan Dataflow di konsolGoogle Cloud . Integrasi dengan Apache Spark, terutama jika dikelola dengan Dataproc, juga tersedia. Komposisi visual integrasi dan
pipeline pemrosesan yang berjalan di Spark + Dataproc dapat dilakukan dengan
Data Fusion.
Pemantauan, Pemberitahuan, dan Logging. Didukung oleh produk Monitoring dan Logging.
Autentikasi dan IAM. Pub/Sub mengandalkan autentikasi OAuth standar
yang digunakan oleh produk Google Cloud lainnya dan mendukung IAM terperinci,
yang memungkinkan kontrol akses untuk setiap resource.
Pemicu, notifikasi, dan webhook. Pub/Sub menawarkan pengiriman pesan berbasis push sebagai permintaan POST HTTP ke webhook. Anda dapat menerapkan otomatisasi alur kerja menggunakan Cloud Functions
atau produk serverless lainnya.
Orkestrasi. Pub/Sub dapat diintegrasikan ke dalam Alur Kerja serverless multi-langkah secara deklaratif. Big data dan orkestrasi analisis sering dilakukan dengan Cloud Composer, yang mendukung pemicu Pub/Sub.
Anda juga dapat mengintegrasikan Pub/Sub dengan Integrasi Aplikasi (Pratinjau) yang merupakan solusi Integration Platform as a Service (iPaaS). Integrasi Aplikasi menyediakan pemicu Pub/Sub untuk memicu atau memulai integrasi.
Integration Connectors.(Pratinjau)
Konektor ini memungkinkan Anda terhubung ke berbagai sumber data.
Dengan konektor, layanan Google Cloud dan aplikasi bisnis pihak ketiga ditampilkan
ke integrasi Anda melalui antarmuka standar yang transparan. Untuk Pub/Sub, Anda dapat membuat koneksi Pub/Sub untuk digunakan dalam integrasi.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-17 UTC."],[],[],null,["# What is Pub/Sub?\n\n| **Key Point:** Understand what is Pub/Sub, why do businesses require Pub/Sub, and the advantages of Pub/Sub compared to similar technologies. Also, learn about core Pub/Sub concepts that include the terms topic, publisher, and subscriber.\n\nPub/Sub is an asynchronous and scalable messaging service that decouples\nservices producing messages from services processing those messages.\n\nPub/Sub allows services to communicate asynchronously, with\nlatencies typically on the order of 100 milliseconds.\n\nPub/Sub is used for streaming analytics and data integration\npipelines to load and distribute data. It's equally effective as a\nmessaging-oriented middleware for service integration or as a queue to parallelize tasks.\n\nPub/Sub lets you create systems of event producers and consumers,\ncalled **publishers** and **subscribers**. Publishers communicate with\nsubscribers asynchronously by broadcasting events, rather than by\nsynchronous remote procedure calls (RPCs).\n\nPublishers send events to the Pub/Sub service, without regard to\nhow or when these events are to be processed. Pub/Sub then\ndelivers events to all the services that react to them. In systems communicating\nthrough RPCs, publishers must wait for subscribers to receive the data. However,\nthe asynchronous integration in Pub/Sub increases the flexibility\nand robustness of the overall system.\n\nTo get started with Pub/Sub, check out the\n[Quickstart using Google Cloud console](/pubsub/docs/create-topic-console).\nFor a more comprehensive introduction, see\n[Building a Pub/Sub messaging system](/pubsub/docs/quickstart-py-mac).\n\nCommon use cases\n----------------\n\n- **Ingesting user interaction and server events.** To use user interaction events from end-user apps or server events from your system, you might forward them to Pub/Sub. You can then use a stream processing tool, such as Dataflow, which delivers the events to databases. Examples of such databases are BigQuery, Bigtable, and Cloud Storage. Pub/Sub lets you gather events from many clients simultaneously.\n- **Real-time event distribution.** Events, raw or processed, may be made available to multiple applications across your team and organization for real- time processing. Pub/Sub supports an \"enterprise event bus\" and event-driven application design patterns. Pub/Sub lets you integrate with many systems that export events to Pub/Sub.\n- **Replicating data among databases.** Pub/Sub is commonly used to distribute change events from databases. These events can be used to construct a view of the database state and state history in BigQuery and other data storage systems.\n- **Parallel processing and workflows.** You can efficiently distribute many tasks among multiple workers by using Pub/Sub messages to communicate with the workers. Examples of such tasks are compressing text files, sending email notifications, evaluating AI models, and reformatting images.\n- **Enterprise event bus.** You can create an enterprise-wide real-time data sharing bus, distributing business events, database updates, and analytics events across your organization.\n- **Data streaming from applications, services, or IoT devices.** For example, a SaaS application can publish a real-time feed of events. Or, a residential sensor can stream data to Pub/Sub for use in other Google Cloud products through a data-processing pipeline.\n- **Refreshing distributed caches.** For example, an application can publish invalidation events to update the IDs of objects that have changed.\n- **Load balancing for reliability.** For example, instances of a service may be deployed on Compute Engine in multiple zones but subscribe to a common topic. When the service fails in any zone, the others can pick up the load automatically.\n\nComparing Pub/Sub to other messaging technologies\n-------------------------------------------------\n\nPub/Sub combines the horizontal scalability of\n[Apache Kafka](/learn/what-is-apache-kafka) and\n[Pulsar](https://pulsar.apache.org/docs/en/2.4.0/concepts-overview/) with\nfeatures found in messaging middleware such as Apache ActiveMQ and\nRabbitMQ. Examples of such features are dead-letter queues and filtering.\n| **Note:** [Google Cloud Managed Service for Apache Kafka](/managed-service-for-apache-kafka/docs/overview) is available. If you're considering a migration from Kafka to Pub/Sub, consult [this migration guide](/architecture/migrating-from-kafka-to-pubsub).\n\nAnother feature that Pub/Sub adopts from messaging middleware is\n**per-message parallelism**, rather than partition-based messaging.\nPub/Sub \"leases\" individual messages to subscriber clients, then\ntracks whether a given message is successfully processed.\n\nBy contrast, other horizontally scalable messaging systems\nuse partitions for horizontal scaling. This forces subscribers\nto process messages in each partition in order and limits the number of concurrent\nclients to the number of partitions. Per-message processing\nmaximizes the parallelism of subscriber applications, and helps ensure\npublisher and subscriber independence.\n\nCompare Service-to-service and service-to-client communication\n--------------------------------------------------------------\n\nPub/Sub is intended for service-to-service communication rather\nthan communication with end-user or IoT clients. Other patterns are\nbetter supported by other products:\n\n- **Client-server.** To send messages between a mobile or web app and a service, use products that include [Firebase Realtime Database](https://firebase.google.com/docs/database) and [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging).\n- **Asynchronous service calls.** Use [Cloud Tasks](/tasks/docs/dual-overview).\n\nYou can use a combination of these services to build client -\\\u003e services -\\\u003e database\npatterns. For example, see the tutorial\n[Streaming Pub/Sub messages over WebSockets](/pubsub/docs/streaming-cloud-pub-sub-messages-over-websockets).\n\nIntegrations\n------------\n\nPub/Sub has many integrations with other Google Cloud products to create a fully\nfeatured messaging system:\n\n- **Stream processing and data integration.** Supported by [Dataflow](/dataflow/docs), including Dataflow [templates](/dataflow/docs/concepts/dataflow-templates) and [SQL](/dataflow/docs/samples/join-streaming-data-with-sql), which allow processing and data integration into BigQuery and data lakes on Cloud Storage. Dataflow templates for moving data from Pub/Sub to Cloud Storage, BigQuery, and other products are available in the Pub/Sub and Dataflow UIs in the Google Cloud console. Integration with [Apache Spark](/learn/what-is-apache-spark), particularly when managed with [Dataproc](/dataproc/docs/concepts/overview) is also available. Visual composition of integration and processing pipelines running on Spark + Dataproc can be accomplished with [Data Fusion](/data-fusion/docs/concepts/overview).\n- **Monitoring, Alerting and Logging.** Supported by Monitoring and Logging products.\n- **Authentication and IAM.** Pub/Sub relies on a standard OAuth authentication used by other Google Cloud products and supports granular IAM, enabling access control for individual resources.\n- **APIs.** Pub/Sub uses standard [gRPC and REST service API\n technologies](/pubsub/docs/apis) along with [client libraries](/pubsub/docs/reference/libraries) for several languages.\n- **Triggers, notifications, and webhooks.** Pub/Sub offers push-based delivery of messages as HTTP POST requests to webhooks. You can implement workflow automation using [Cloud Functions](/functions/docs) or other serverless products.\n- **Orchestration.** Pub/Sub can be integrated into multistep serverless [Workflows](/workflows) declaratively. Big data and analytic orchestration often done with [Cloud Composer](/composer/docs), which supports Pub/Sub triggers. You can also integrate Pub/Sub with [Application Integration](/application-integration/docs/overview) ([Preview](/products#product-launch-stages)) which is an Integration-Platform-as-a-Service (iPaaS) solution. Application Integration provides a [Pub/Sub trigger](/application-integration/docs/configuring-pubsub-trigger) to trigger or start integrations.\n- **Integration Connectors.** ([Preview](/products#product-launch-stages)) These [connectors](/integration-connectors/docs/about-connectors) let you connect to various data sources. With connectors, both Google Cloud services and third-party business applications are exposed to your integrations through a transparent, standard interface. For Pub/Sub, you can create a Pub/Sub [connection](/integration-connectors/docs/connectors/cloudpub/sub/configure) for use in your integrations.\n\nNext steps\n----------\n\n- Get started with the Pub/Sub [quickstart](/pubsub/docs/create-topic-console).\n- Read the [basics of the\n Pub/Sub service](/pubsub/docs/pubsub-basics).\n- Learn how to [build a\n Pub/Sub messaging system](/pubsub/docs/quickstart-py-mac).\n- Understand Pub/Sub [pricing](/pubsub/pricing).\n- Understand quotas and limits for [Pub/Sub](/pubsub/quotas).\n- Read the Pub/Sub [release\n notes](/pubsub/docs/release-notes).\n- [Explore data\n engineering with Google Cloud services](https://www.qwiklabs.com/courses/1530?catalog_rank=%7B%22rank%22%3A3%2C%22num_filters%22%3A0%2C%22has_search%22%3Atrue%7D&search_id=10146692) on Qwiklabs."]]