วางแผนเพื่อหลีกเลี่ยงการจำกัดอัตราคำขอ
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Health Connect กำหนดขีดจำกัดอัตราการเชื่อมต่อไคลเอ็นต์กับ Health Connect API เพื่อรักษาความเสถียรและประสิทธิภาพของระบบให้ดีที่สุด
คู่มือนี้จะอธิบายขีดจำกัดของการดำเนินการ API สำหรับการอ่านและการเขียนใน Health Connect และวิธีหลีกเลี่ยงการจำกัดอัตราผ่านการออกแบบแอปที่มีประสิทธิภาพ
ขีดจำกัด API
ระบบจะกำหนดขีดจำกัดทั้งการดำเนินการ API ที่ทำงานอยู่เบื้องหน้าและเบื้องหลังเป็นโควต้าอัตราคำขอ
แบบคงที่
ขีดจำกัดอัตราและหน่วยความจำจะแตกต่างกันไปตามประเภทการดำเนินการที่แอปของคุณ
ดำเนินการ และการดำเนินการนั้นเกิดขึ้นในเบื้องหน้าหรือเบื้องหลัง
อ่านและเปลี่ยนบันทึกการเปลี่ยนแปลง
สำหรับขีดจำกัดการอ่านและบันทึกการเปลี่ยนแปลง Health Connect จะกำหนดขีดจำกัด 2 อย่างเกี่ยวกับจำนวนการเรียก API ที่แอปของคุณใช้ได้ ดังนี้
- ขีดจำกัดเป็นระยะสำหรับจำนวนการเรียก API ที่แอปของคุณทำได้ต่อ API
- ขีดจำกัดรายวันของจำนวนการเรียก API ที่แอปของคุณทำได้
แทรก อัปเดต และลบขีดจำกัด
Health Connect กำหนดขีดจำกัดที่แตกต่างกัน 4 อย่างในการดำเนินการแทรก อัปเดต และลบ
- ขีดจำกัดเป็นระยะสำหรับจำนวนการเรียกที่แอปทำได้ต่อ API
- ขีดจำกัดรายวันของจำนวนการเรียกที่แอปทำได้ต่อ API
- ขีดจำกัดหน่วยความจำสำหรับการแทรกข้อมูลจำนวนมาก
- ขีดจำกัดหน่วยความจำสำหรับการแทรกระเบียนเดียว
แนวทางปฏิบัติแนะนำ
เราขอแนะนำให้แอปโต้ตอบกับ Health Connect API ในลักษณะที่
ลดการใช้แบตเตอรี่ รักษาประสิทธิภาพของระบบ และส่งเสริม
การจัดการข้อมูลที่มีประสิทธิภาพในการดำเนินการ CRUD ทั้งหมด
ต่อไปนี้คือหลักเกณฑ์แนวทางปฏิบัติแนะนำที่คุณควรปฏิบัติตาม
การเรียก API ในเบื้องหลัง
การใช้แบตเตอรี่สำหรับการดำเนินการในเบื้องหลังจะลดประสบการณ์ของผู้ใช้และทำให้เกิดข้อสงสัยเกี่ยวกับความเป็นส่วนตัวของข้อมูล
ดังนั้น การจำกัดอัตราในเบื้องหลังจึงเข้มงวดกว่าการจำกัดอัตราในเบื้องหน้า
ดังนั้นจึงควรจำกัดจำนวนการเรียก API ที่แอปของคุณดำเนินการ
ในเบื้องหลัง
การจัดการข้อยกเว้น
หากแอปของคุณพบข้อยกเว้นเมื่อเขียนข้อมูลไปยัง Health Connect เราขอแนะนำให้ลองอีกครั้งจากจุดที่เกิดข้อยกเว้น
อย่าเพียงแค่ลบข้อมูลทั้งหมดที่เป็นปัญหาและลองส่งคำขอเขียนทั้งหมดอีกครั้ง
วิธีนี้จะใช้โควต้าการแทรก ลดประสิทธิภาพ และส่งผลเสียต่ออายุการใช้งานแบตเตอรี่
การจัดการบันทึกการเปลี่ยนแปลง
หากต้องการลดความเสี่ยงที่แอปจะถูกจำกัดอัตรา คุณควรใช้การจัดการบันทึกการเปลี่ยนแปลงเพื่อซิงค์ฐานข้อมูลกับข้อมูลจาก Health Connect แทนที่จะพึ่งพาคำขออ่านดิบมากเกินไป
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],null,["# Plan to avoid rate limiting\n\nTo maintain optimal system stability and performance, Health Connect imposes\nrate limits on client connections to the Health Connect API.\n\nThis guide outlines the limits imposed on read and write API operations in\nHealth Connect, and how to avoid rate limiting through efficient app design.\n\nAPI limits\n----------\n\nLimits are placed on both foreground and background API operations as **fixed\nrequest rate quotas**.\n\nRate and memory limits are variable based on the type of operation your app is\nperforming, and whether that operation occurs in the foreground or background.\n\n### Read and changelog limits\n\nFor read and changelog limits, Health Connect imposes two limits on the number\nof API calls available to your app:\n\n- A periodic limit on the number of API calls your app can make to the API.\n- A daily limit on the number of API calls your app can make.\n\n### Insert, update and delete limits\n\nHealth Connect places four distinct limits on insertion, update and deletion\noperations:\n\n- A periodic limit on the number of calls your app can make to the API.\n- A daily limit on the number of calls your app can make to the API.\n- A memory limit for bulk insertions.\n- A memory limit for single record insertions.\n\nBest practices\n--------------\n\nWe recommend that apps interact with the Health Connect API in a way that\nminimizes battery use, maintains optimal system health and promotes efficient\ndata management across all CRUD operations.\n\nHere are some best practice guidelines to adhere to.\n\n### Background API calls\n\nBattery usage for background operations reduces the user experience and raises\nquestions regarding [data privacy](/guide/health-and-fitness/health-connect/develop/read-data#foreground-restriction).\n\nAs such, background rate limiting is stricter than foreground rate limiting.\nIt's therefore important to limit the amount of API calls your app carries out\nin the background.\n\n### Exception handling\n\nIf your app experiences an exception when writing data to Health Connect, we\nrecommend retrying from where the exception occurred.\n\nDon't simply delete all the data in question and retry the entire write request.\nThis approach eats into your insert quota, reduces performance, and has a\nnegative impact on battery life.\n\n### Changelog handling\n\nTo minimize the risk of your app being rate limited, you should utilize\n[changelog handling](/guide/health-and-fitness/health-connect/develop/sync-data#pull-data) to synchronize your database with data from Health\nConnect, rather than over-relying on raw read requests."]]