DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Building Gateway Analytics: My Journey to Making API Traffic Data Useful
  • API Analytics: Unleashing the Power of Data-Driven Insights for Enhanced API Management
  • The Rising Risks and Opportunities in API Security
  • Good Data, Bad Metric: A Mutation Testing Pattern for Analytics Engineering

Trending

  • Building Threat Intelligence Pipelines Using Python, APIs, and Elasticsearch
  • Building a Zero-Cost Approval Workflow With AWS Lambda Durable Functions
  • Building AI-Powered Java Applications With Jakarta EE and LangChain4j
  • 5 AI Security Incidents That Broke Things in Production (and What They Have in Common)
  1. DZone
  2. Data Engineering
  3. Data
  4. What Is Dynamic Sampling and How It Works

What Is Dynamic Sampling and How It Works

Sometimes you may want to limit the amount of analytics data coming into your API management program. Learn to optimize your data with dynamic sampling!

By 
Dylan Frankcom user avatar
Dylan Frankcom
·
Nov. 08, 23 · Analysis
Likes (2)
Comment
Save
Tweet
Share
2.2K Views

Join the DZone community and get the full member experience.

Join For Free

Sometimes you may want to limit the amount of analytics data coming into your API management tool. This could be because you want to exclude specific traffic, such as internal or health check traffic, or you may want to reduce unnecessary data to control cost. Dynamic sampling does just this. Dynamic sampling lets you control which API calls are logged to your API management tool based on customer or API behavior. Intelligently extrapolate metrics for accurate reporting even with multiple sample rates so that no matter what rules or sample rates you have set up, you can be sure you are still seeing an accurate representation of your data.

Dynamic sampling is controlled by setting up sampling rules in the API management tool's dashboard. You can create rules based on criteria such as request path, response status codes, user or company behaviors, and more. You can also control the applied sample rate for each rule. The sample rate is the percentage of events that will make their way into your API management tool. For example, if you set a rule to sample 50% of events, your management tool will log half of the matching events intelligently (and not just log every other event to meet the 50% sampling rate).

Why Use Dynamic Sampling?

Dynamic sampling serves two use cases:

  • Gives users the capability to trim down excessive or uninteresting calls populating while retaining the insight you gain from the platform.
  • Allows users to reduce subscription costs and save money. 

When Not to Use Dynamic Sampling

It would be best if you avoided dynamic sampling on specific events moving into your API management tool. 

Dynamically sampling the number of API calls coming into your API management tool would impact a monetized API because it would fail to track the exact usage, likely missing some events depending on the sampling rate applied. This will affect your billing meters and the invoices being sent to customers. However, a way around this is to apply dynamic sampling to endpoints that are not monetized and let events counted within your Billing Meter sample at 100%.

Another reason not to use dynamic sampling is when your logged API calls are less than the number of calls your subscription plan supports. For example, suppose you are making fewer API calls than your subscription plan includes. In that case, dynamic sampling is unnecessary unless you are simply trying to exclude data you don’t want in your management tool to keep data cleaner. Examples of this may be not including traffic from health check probes or internal testing.

Four Types of Sample Rates

Dynamic sampling rules are categorized into four kinds of sample sets and are prioritized in the following manner:

  • Sample rates for a single user or company
  • Sample rates based on regex rules
  • Sample rates based on user behaviors and demographics (Saved Cohorts)
  • Sample rates applied globally

This means that if a sample rate is set for a specific customer, this will take priority over a sample rate associated with a behavioral cohort that a customer belongs to. Global sample rates have the lowest priority and are, by default, set to 100% for all customers. If an API call matches multiple rules, it gets processed by the first kind of sample rate in the prioritization hierarchy.

In conclusion, utilizing dynamic sampling for API products offers a smart and effective strategy to maximize the benefits of your API offerings. By adapting to evolving data requirements and usage patterns in real-time, dynamic sampling ensures resource efficiency, cost control, and responsive performance, all while maintaining data security and compliance. This approach not only enhances user experience but also positions your users to harness the full potential of your API in a sustainable and agile manner, making it a crucial tool for the success of modern API products.

API Analytics Data (computing)

Published at DZone with permission of Dylan Frankcom. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Building Gateway Analytics: My Journey to Making API Traffic Data Useful
  • API Analytics: Unleashing the Power of Data-Driven Insights for Enhanced API Management
  • The Rising Risks and Opportunities in API Security
  • Good Data, Bad Metric: A Mutation Testing Pattern for Analytics Engineering

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook