Push vs. Pull in IT: More Than You Think

Jimin
5 min readDec 31, 2024

--

There’s a joke in Korea: If you want to spot who’s Korean, watch how they open a door. They’ll push the door — no matter whether it’s labeled “Pull” or “Push.” And when the door says “Fixed” (meaning locked), they’ll jiggle with the handle.

It’s funny because it’s often true — I do the same. Perhaps it reflects Koreans’ hasty nature, as we rarely take a moment to carefully read the sign.

But in the IT world, “push” and “pull” have meanings that take on additional meanings beyond physical actions. These concepts form the foundation of how data, tasks, or responsibilities flow between systems.

A door of a Korean restaurant, covered with multiple “Pull” signs, reflecting the owner’s frustration with customers ignoring clear instructions.

Push and Pull in Applications

At its core, the push-pull pattern defines how interactions between systems are initiated:

  • Pull: The recipient actively requests or retrieves data. Think of it as the system saying, “I’ll take what I need when I need it.
  • Push: The sender proactively delivers data to the recipient. In this case, the system operates on the idea of, “Here is what you need, whether you asked for it or not.

The decision to use push, pull, or a combination of both depends on the system’s requirements for latency, scalability, and complexity.

1. API Integrations: From Polling to Webhooks

As developers, we often face situations where one system needs to stay updated with another — like fetching weather updates, stock prices, or real-time notifications. The approach taken to transfer this data can reflect either a pull or push mechanism:

  • Polling (Pull): Represents the pull mechanism, where the recipient actively requests updates from the server. It’s like asking, “Do you have anything new for me?” RESTful APIs usually follow this pull approach, where the client requests data from the server as needed.
  • Webhooks (Push): Embody the push mechanism, where the server proactively sends updates to the recipient as soon as something changes. It’s like saying, “Here’s the latest update, right when you need it.” For example, Stripe sends a webhook to notify clients about payment status changes.

In this context, pull gives you control over when and what to retrieve, while push delivers data instantly, reducing latency.

2. Notifications: User Alerts in Apps

You’re building a mobile app that sends reminders for upcoming events. How should notifications be delivered?

  • Pull Notification: Your app fetches notifications only when a user logs in and checks their inbox. This approach minimizes server-to-device communication but requires user interaction to retrieve updates.
  • Push Notification: Your app uses push notifications to alert users in real time. The server delivers messages directly to users’ devices as soon as an event is triggered — perfect for urgent or time-sensitive updates. Messaging apps like WhatsApp or Slack rely heavily on this.

Here, pull shifts responsibility to the user, while push ensures immediacy.

3. Data Synchronization: Collaboration Tools

For collaboration tools like Google Docs, push and pull play key roles in data synchronization:

  • State Pull: Retrieving the current state upon reconnection or on-demand, often referred to as state synchronization or lazy synchronization, where updates are fetched to align with the source.
  • State Push: Actively propagating changes from one system to others in real-time. This aligns with event-driven architecture, where events (e.g., a user typing) trigger immediate updates to other connected clients.

Pull ensures consistency after disruptions, while push offers real-time collaboration.

4. Web Content Delivery: Real-Time Updates vs. On-Demand Requests

Consider a news website that updates its homepage with breaking news:

  • HTTP Requests (Pull): Traditional HTTP requests require the client to explicitly request updates by navigating to a URL or refreshing the page, retrieving the latest data only on demand.
  • Server-Sent Events (Push): Server-Sent Events (SSE) or WebSockets enable real-time updates by delivering live data directly to the client as events occur. This ensures users receive breaking news instantly without needing to refresh the page.

Pull-based HTTP requests offer users more control over when they retrieve updates, while push mechanisms like SSE create a seamless, real-time experience.

5. Monitoring and Alerting

  • Prometheus Default Mode (Pull): Prometheus scrapes metrics from endpoints at regular intervals, ensuring the system actively retrieves data it needs to monitor applications.
  • Prometheus with Pushgateway (Push): Services send their metrics directly to Prometheus via the Pushgateway, an approach suitable for short-lived jobs that may not be accessible for pulling.

6. Messaging and Streaming

  • RSS Feeds (Pull): Readers periodically check for new posts from RSS feeds, operating entirely on a pull-based mechanism.
  • Apache Kafka (Push): Producers push messages to Kafka topics, allowing consumers to subscribe and retrieve messages dynamically, creating a hybrid push-pull system.

Choosing Between Push and Pull

The decision to use push, pull, or a combination hinges on specific system needs:

  • Latency: Pull introduces some delay since the recipient determines when to fetch data. Push reduces latency by delivering data immediately, making it ideal for real-time scenarios.
  • Scalability: Pull can scale better for large systems, as recipients control the load. Push might overwhelm recipients if not managed carefully.
  • Complexity: Pull is simpler to implement with traditional request-response paradigms. Push mechanisms often require a persistent connection (e.g., WebSockets), adding complexity.

Push and Pull in CI/CD Workflows

While exploring push and pull mechanisms, it’s worth addressing a potential point of confusion. The terms “push” and “pull” are commonly used in tools like Git and Docker. However, in these contexts, they refer to specific operations for transferring code or artifacts rather than the system-initiated or client-initiated actions discussed earlier. In CI/CD workflows, these terms integrate into automated pipelines to manage code sharing, artifact synchronization, and deployment.

Here’s how these principles apply in CI/CD processes:

1. Git: Triggering the CI/CD Pipeline

The process begins when a developer pushes code changes to a Git repository.

  • git push: Using git push, the developer proactively sends updates from their local machine to the remote repository. This act not only publishes the changes but also triggers the CI/CD pipeline, where automated processes kick off tasks like running tests, building artifacts, and generating reports.
  • git pull: Other developers or systems may later use git pull to retrieve these updates, ensuring their environments stay in sync with the latest codebase.

2. Docker Images: Pushing and Pulling Artifacts

As part of the CI/CD pipeline, containerization plays a crucial role in packaging the application and its dependencies into Docker images.

  • docker push: During the build stage, the pipeline generates a Docker image of the application. This image is then pushed to a container registry (e.g., Docker Hub, Amazon ECR). Pushing the image makes it available for other pipeline stages or environments like staging and production.
  • docker pull: In subsequent deployment stages, the environment (such as a Kubernetes cluster) pulls the Docker image from the registry. This ensures that the application is deployed with the exact version built earlier in the pipeline, maintaining consistency across environments.

3. CI/CD: The Flow of Push and Pull

Let’s connect the dots in a complete CI/CD process:

  1. Push to Git: A developer pushes code to a Git repository, triggering the CI/CD pipeline.
  2. Pipeline Builds and Pushes Docker Images:
    - The pipeline builds the application and packages it into a Docker image.
    - The Docker image is pushed to a container registry for storage and accessibility.
  3. Pull for Deployment:
    - In the deployment stage, the production or staging environment pulls the Docker image from the registry.
    - This pull mechanism ensures that the exact image created during the build process is used for deployment, maintaining consistency.

--

--

Jimin
Jimin

Written by Jimin

DevOps engineer and tech enthusiast. Sharing tech insights to simplify the complex. Let's connect on LinkedIn! https://www.linkedin.com/in/byun-jimin/

No responses yet