Pub/Sub는 메시지를 생성하는 서비스를 해당 메시지를 처리하는 서비스에서 분리하는 확장 가능한 비동기 메시징 서비스입니다.
Pub/Sub를 통해 서비스는 비동기적으로 통신할 수 있으며, 일반적으로 지연 시간은 100밀리초 정도입니다.
Pub/Sub는 데이터를 로드하고 배포하는 스트리밍 분석 및 데이터 통합 파이프라인에 사용됩니다. 이는 서비스 통합을 위한 메시징 중심 미들웨어 또는 태스크 병렬화를 위한 큐로도 효과적입니다.
Pub/Sub를 사용하면 게시자 및 구독자라는 이벤트 제작자 및 소비자 시스템을 만들 수 있습니다. 게시자는 동기식 리모트 프로시져 콜(RPC)이 아니라 이벤트를 브로드캐스트하여 구독자와 비동기적으로 통신합니다.
게시자는 이러한 이벤트가 처리되는 방식이나 시기에 관계없이 Pub/Sub 서비스에 이벤트를 보냅니다. 그런 다음 Pub/Sub는 이벤트에 응답하는 모든 서비스에 이벤트를 전송합니다. RPC를 통해 통신하는 시스템에서 게시자는 구독자가 데이터를 수신할 때까지 기다려야 합니다. 그러나 Pub/Sub에서 비동기 통합은 전반적인 시스템의 유연성과 견고성을 높여줍니다.
사용자 상호작용 및 서버 이벤트 수집 최종 사용자 앱의 사용자 상호작용 이벤트 또는 시스템의 서버 이벤트를 사용하려면 이를 Pub/Sub로 전달해야 할 수 있습니다. 그런 후 이벤트를 데이터베이스로 전송하는 Dataflow와 같은 스트림 처리 도구를 사용할 수 있습니다. 이러한 데이터베이스의 예로는 BigQuery, Bigtable, Cloud Storage가 있습니다.
Pub/Sub를 사용하면 여러 클라이언트의 이벤트를 동시에 수집할 수 있습니다.
실시간 이벤트 배포. 원시 또는 처리된 이벤트를 팀과 조직 전체의 여러 애플리케이션에서 실시간으로 처리할 수 있습니다. Pub/Sub는 '엔터프라이즈 이벤트 버스' 및 이벤트 기반 애플리케이션 설계 패턴을 지원합니다.
Pub/Sub를 사용하면 이벤트를 Pub/Sub로 내보내는 여러 시스템과 통합할 수 있습니다.
데이터베이스 간 데이터 복제. Pub/Sub는 일반적으로 데이터베이스의 변경 이벤트를 배포하는 데 사용됩니다. 이러한 이벤트는 BigQuery 및 다른 데이터 스토리지 시스템에서 데이터베이스 상태 및 상태 기록의 뷰를 구성하는 데 사용될 수 있습니다.
병렬 처리 및 워크플로. Pub/Sub 메시지를 사용하여 작업자와 통신하면 여러 작업자 간에 많은 태스크를 효율적으로 배포할 수 있습니다. 이러한 태스크의 예시에는 텍스트 파일 압축, 이메일 알림 전송, AI 모델 평가, 이미지 형식 재지정이 있습니다.
엔터프라이즈 이벤트 버스. 전사적 실시간 데이터 공유 버스를 만들어 비즈니스 이벤트, 데이터베이스 업데이트, 분석 이벤트를 조직 전체에 배포할 수 있습니다.
애플리케이션, 서비스, IoT 기기에서 데이터 스트리밍.
예를 들어 SaaS 애플리케이션은 이벤트의 실시간 피드를 게시할 수 있습니다. 또는 가정용 센서가 데이터 처리 파이프라인을 통해 다른 Google Cloud 제품에서 사용할 수 있도록 Pub/Sub로 데이터를 스트리밍할 수 있습니다.
분산 캐시 갱신. 예를 들어 애플리케이션이 무효화 이벤트를 게시하여, 변경된 객체의 ID를 업데이트합니다.
안정성을 위한 부하 분산. 예를 들어 서비스 인스턴스가 여러 영역에 있는 Compute Engine에 배포되어도 공통 주제를 구독할 수 있습니다. 영역에 장애가 발생하면 나머지가 자동으로 부하를 선택합니다.
Pub/Sub와 다른 메시징 기술 비교
Pub/Sub는 Apache Kafka 및 Pulsar의 수평적 확장성을 Apache ActiveMQ 및 RabbitMQ와 같은 메시징 미들웨어의 기능과 결합합니다. 이러한 기능의 예시에는 데드 레터 큐와 필터링이 있습니다.
Pub/Sub가 메시징 미들웨어에서 사용하는 또 다른 기능은 파티션 기반 메시징이 아닌 메시지당 동시 로드입니다.
Pub/Sub는 개별 메시지를 구독자 클라이언트에 '임대'한 다음 지정된 메시지가 성공적으로 처리되었는지 주기적으로 확인합니다.
반대로 다른 수평 확장형 메시지 시스템은 수평 확장에 파티션을 사용합니다. 이렇게 하면 구독자가 각 파티션에서 메시지를 순서대로 처리해야 하며 동시 클라이언트 수가 파티션 수로 제한됩니다. 메시지당 처리는 구독자 애플리케이션의 동시 로드를 극대화하고 게시자 및 구독자의 독립성을 보장하는 데 도움이 됩니다.
서비스 간 통신 및 서비스-클라이언트 간 통신 비교
Pub/Sub의 용도는 최종 사용자 또는 IoT 클라이언트와의 통신이 아닌 서비스 간 통신입니다. 다른 제품에서는 다른 패턴이 더 잘 지원됩니다.
Pub/Sub는 다른 Google Cloud 제품과 많이 통합되어 모든 기능을 갖춘 메시징 시스템을 만듭니다.
스트림 처리 및 데이터 통합. Dataflow 템플릿 및 SQL을 포함한 Dataflow에서 지원되며 이를 통해 데이터를 처리하고 Cloud Storage에서 BigQuery 및 데이터 레이크에 데이터를 통합할 수 있습니다. Pub/Sub에서 Cloud Storage, BigQuery, 기타 제품으로 데이터를 이동하는 Dataflow 템플릿은Google Cloud 콘솔의 Pub/Sub 및 Dataflow UI에서 사용할 수 있습니다. 특히 Dataproc으로 관리되는 경우 Apache Spark와의 통합도 사용할 수 있습니다. Spark + Dataproc에서 실행되는 통합 및 처리 파이프라인의 시각적 구성은 Data Fusion을 사용하여 수행할 수 있습니다.
모니터링, 알림, 로깅. Monitoring 및 Logging 제품에서 지원됩니다.
인증 및 IAM Pub/Sub는 다른 Google Cloud 제품에서 사용하는 표준 OAuth 인증을 사용하며 세분화된 IAM을 지원하여 개별 리소스에 대한 액세스 제어를 지원합니다.
트리거, 알림, 웹훅. Pub/Sub는 웹훅에 대한 HTTP POST 요청으로 푸시 기반의 메시지 전송을 제공합니다. Cloud Functions 또는 기타 서버리스 제품을 사용하여 워크플로 자동화를 쉽게 구현할 수 있습니다.
조정. Pub/Sub는 여러 단계의 서버리스 워크플로에 선언적으로 통합할 수 있습니다. 빅데이터 및 분석 조정은 종종 Pub/Sub 트리거를 지원하는 Cloud Composer로 이루어집니다.
또한 Pub/Sub를 Integration-Platform-as-a-Service(iPaaS) 솔루션인 Application Integration(미리보기)과 통합할 수 있습니다. Application Integration은 통합을 트리거하거나 시작하는 Pub/Sub 트리거를 제공합니다.
Integration Connectors.(미리보기)
이러한 커넥터를 사용하여 다양한 데이터 소스에 연결할 수 있습니다.
커넥터를 사용하면 Google Cloud 서비스 및 서드 파티 비즈니스 애플리케이션이 모두 투명한 표준 인터페이스를 통해 통합에 제공됩니다. Pub/Sub의 경우, 통합에 사용할 Pub/Sub 연결을 만들 수 있습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(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."]]