सबसे सही तरीके और सीमाएं
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
BatchJobService
का इस्तेमाल करते समय इन दिशा-निर्देशों का ध्यान रखें.
थ्रूपुट को बेहतर बनाना
कई छोटी नौकरियों के बजाय, कुछ बड़ी नौकरियों को प्राथमिकता दी जाती है.
अपलोड की गई कार्रवाइयों को ऑपरेशन टाइप के हिसाब से क्रम में लगाएं. उदाहरण के लिए, अगर आपकी जॉब में कैंपेन, विज्ञापन ग्रुप, और विज्ञापन ग्रुप की शर्तें जोड़ने के लिए ऑपरेशन शामिल हैं, तो अपलोड में ऑपरेशन का क्रम इस तरह से तय करें कि पहले सभी कैंपेन ऑपरेशन, उसके बाद सभी विज्ञापन ग्रुप ऑपरेशन, और आखिर में सभी विज्ञापन ग्रुप की शर्तों के ऑपरेशन हों.
एक ही तरह के ऑपरेशन में, पैरंट रिसॉर्स के हिसाब से उन्हें ग्रुप करने से परफ़ॉर्मेंस बेहतर हो सकती है. उदाहरण के लिए, अगर आपके पास AdGroupCriterionOperation
ऑब्जेक्ट की सीरीज़ है, तो अलग-अलग विज्ञापन ग्रुप में विज्ञापन ग्रुप की शर्तों पर असर डालने वाले ऑपरेशन को इंटरमिक्स करने के बजाय, ऑपरेशन को विज्ञापन ग्रुप के हिसाब से ग्रुप करना ज़्यादा असरदार हो सकता है.
एक साथ कई टास्क करने से जुड़ी समस्याओं से बचना
एक ही खाते के लिए एक साथ कई जॉब सबमिट करते समय, एक ही समय पर एक ही ऑब्जेक्ट पर जॉब चलने की संभावना को कम करने की कोशिश करें. साथ ही, जॉब के बड़े साइज़ को बनाए रखें. कई अधूरे जॉब, जिनका स्टेटस RUNNING
है, ऑब्जेक्ट के एक ही सेट में बदलाव करने की कोशिश करते हैं. इससे डेडलॉक जैसी स्थितियां पैदा हो सकती हैं. इसकी वजह से, प्रोसेस बहुत धीमी हो जाती है और जॉब पूरा नहीं हो पाता.
एक ही जॉब में एक ही ऑब्जेक्ट में बदलाव करने वाले कई ऑपरेशन सबमिट न करें, क्योंकि नतीजा अनुमानित नहीं हो सकता.
बेहतर नतीजे पाना
जॉब के स्टेटस को बार-बार पॉल न करें. ऐसा करने पर, अनुरोध करने की दर से जुड़ी गड़बड़ियां हो सकती हैं.
हर पेज पर 1,000 से ज़्यादा नतीजे न पाएं. लोड या अन्य वजहों से, सर्वर इससे कम एलिमेंट दिखा सकता है.
नतीजों का क्रम, अपलोड करने के क्रम जैसा ही होगा.
इस्तेमाल से जुड़े अन्य दिशा-निर्देश
आपके पास यह तय करने का विकल्प होता है कि किसी बैच जॉब को रद्द किए जाने से पहले, उसे कितनी देर तक चलने की अनुमति है. नई बैच जॉब बनाते समय, metadata.execution_limit_seconds
फ़ील्ड को सेकंड में अपनी पसंदीदा समयसीमा पर सेट करें. अगर metadata.execution_limit_seconds
सेट नहीं है, तो डिफ़ॉल्ट समयसीमा नहीं होगी.
हमारा सुझाव है कि हर AddBatchJobOperationsRequest
में ज़्यादा से ज़्यादा 1,000 ऑपरेशन जोड़ें. साथ ही, बाकी ऑपरेशन को उसी जॉब में अपलोड करने के लिए, sequence_token
का इस्तेमाल करें. ऑपरेशन के कॉन्टेंट के आधार पर, एक ही AddBatchJobOperationsRequest
में बहुत ज़्यादा ऑपरेशन करने पर, REQUEST_TOO_LARGE
गड़बड़ी हो सकती है. ऑपरेशन की संख्या कम करके और फिर से AddBatchJobOperationsRequest
को आज़माकर, इस गड़बड़ी को ठीक किया जा सकता है.
सीमाएं
हर BatchJob
, एक मिलियन ऑपरेशन तक के साथ काम करता है.
हर खाते में एक ही समय पर, ज़्यादा से ज़्यादा 100 चालू या बाकी नौकरियां हो सकती हैं.
सात दिन से ज़्यादा पुराने, पूरे नहीं किए गए जॉब अपने-आप हट जाते हैं.
हर AddBatchJobOperationsRequest
का साइज़ ज़्यादा से ज़्यादा 10,484,504 बाइट हो सकता है. इस सीमा से ज़्यादा डेटा अपलोड करने पर, आपको INTERNAL_ERROR
मिलेगा. सबमिट करने से पहले, अनुरोध का साइज़ तय किया जा सकता है. अगर अनुरोध का साइज़ बहुत बड़ा है, तो उस पर ज़रूरी कार्रवाई की जा सकती है.
Java
static final int MAX_REQUEST_BYTES = 10_484_504;
... (code to get the request object)
int sizeInBytes = request.getSerializedSize();
Python
from google.ads.googleads.client import GoogleAdsClient
MAX_REQUEST_BYTES = 10484504
... (code to get the request object)
size_in_bytes = request._pb.ByteSize()
Ruby
require 'google/ads/google_ads'
MAX_REQUEST_BYTES = 10484504
... (code to get the request object)
size_in_bytes = request.to_proto.bytesize
PHP
use Google\Ads\GoogleAds\V16\Resources\Campaign;
const MAX_REQUEST_BYTES = 10484504;
... (code to get the request object)
$size_in_bytes = $campaign->byteSize() . PHP_EOL;
.NET
using Google.Protobuf;
const int MAX_REQUEST_BYTES = 10484504;
... (code to get the request object)
int sizeInBytes = request.ToByteArray().Length;
Perl
use Devel::Size qw(total_size);
use constant MAX_REQUEST_BYTES => 10484504;
... (code to get the request object)
my $size_in_bytes = total_size($request);
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-09-05 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-09-05 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eTo improve throughput when using BatchJobService, submit fewer, larger jobs and order operations by type and parent resource to enhance efficiency.\u003c/p\u003e\n"],["\u003cp\u003eWhen running concurrent jobs, minimize the likelihood of them operating on the same objects simultaneously to avoid potential deadlock-like conditions and job failures.\u003c/p\u003e\n"],["\u003cp\u003eFor optimal results retrieval, avoid excessive job status polling and retrieve results in batches of 1,000 or less to prevent rate limit errors and ensure efficient data handling.\u003c/p\u003e\n"],["\u003cp\u003eBatchJobService allows setting an execution time limit and recommends a maximum of 1,000 operations per request to avoid exceeding size limitations and potential errors.\u003c/p\u003e\n"],["\u003cp\u003eEach BatchJob is subject to limitations, including a maximum of one million operations, 100 active or pending jobs per account, a 7-day lifespan for pending jobs, and a request size limit of 10,484,504 bytes.\u003c/p\u003e\n"]]],[],null,["# Best Practices and Limitations\n\nConsider these guidelines when using [`BatchJobService`](/google-ads/api/reference/rpc/v21/BatchJobService).\n\nImprove throughput\n------------------\n\n- Fewer larger jobs is preferred over many smaller jobs.\n\n- Order uploaded operations by operation type. For example, if your job\n contains operations to add campaigns, ad groups, and ad group criteria,\n order the operations in your upload so that all of the [campaign\n operations](/google-ads/api/reference/rpc/v21/CampaignOperation) are first, followed by all of\n the [ad group operations](/google-ads/api/reference/rpc/v21/AdGroupOperation), and finally all\n [ad group criterion operations](/google-ads/api/reference/rpc/v21/AdGroupCriterionOperation).\n\n- Within operations of the same type, it can improve performance to group them\n by parent resource. For example, if you have a series of\n `AdGroupCriterionOperation` objects, it can be more efficient to group\n operations by ad group, rather than intermixing operations that affect ad\n group criteria in different ad groups.\n\nAvoid concurrency issues\n------------------------\n\n- When submitting multiple concurrent jobs for the same account, try to reduce\n the likelihood of jobs operating on the same objects at the same time, while\n maintaining large job sizes. Many unfinished jobs, which have the status of\n [`RUNNING`](/google-ads/api/reference/rpc/v21/BatchJobStatusEnum.BatchJobStatus#running),\n try to mutate the same set of objects, which can lead to deadlock-like\n conditions resulting in severe slow-down and even job failures.\n\n- Don't submit multiple operations that mutate the same object in the same\n job, as the result can be unpredictable.\n\nRetrieve results optimally\n--------------------------\n\n- Don't poll the job status too frequently or you risk hitting rate limit\n errors.\n\n- Don't retrieve more than 1,000 results per page. The server could return\n fewer than that due to load or other factors.\n\n- The results order will be the same as the upload order.\n\nAdditional usage guidance\n-------------------------\n\n- You can set an upper bound for how long a batch job is allowed to run before\n being cancelled. When creating a new batch job, set the\n [`metadata.execution_limit_seconds`](/google-ads/api/reference/rpc/v21/BatchJob.BatchJobMetadata#execution_limit_seconds)\n field to your preferred time limit, in seconds. There is no default time\n limit if `metadata.execution_limit_seconds` is not set.\n\n- It is recommended to add no more than 1,000 operations per\n [`AddBatchJobOperationsRequest`](/google-ads/api/reference/rpc/v21/BatchJobService/AddBatchJobOperations)\n and use the\n [`sequence_token`](/google-ads/api/reference/rpc/v21/AddBatchJobOperationsRequest#sequence_token)\n to upload the rest of the operations to the same job. Depending on the\n content of the operations, too many operations in a single\n `AddBatchJobOperationsRequest` could cause a [`REQUEST_TOO_LARGE`](/google-ads/api/reference/rpc/v21/DatabaseErrorEnum.DatabaseError#request_too_large) error. You\n can handle this error by reducing the number of operations and retrying the\n `AddBatchJobOperationsRequest`.\n\nLimitations\n-----------\n\n- Each [`BatchJob`](/google-ads/api/reference/rpc/v21/BatchJob) supports up to one million\n operations.\n\n- Each account can have up to 100 active or pending jobs at the same time.\n\n- Pending jobs older than 7 days are automatically removed.\n\n- Each [`AddBatchJobOperationsRequest`](/google-ads/api/reference/rpc/v21/BatchJobService/AddBatchJobOperations)\n has a maximum size of 10,484,504 bytes. If you exceed this, you will receive\n an `INTERNAL_ERROR`. You can determine the size of the request before\n submitting and take appropriate action if it is too large.\n\n ### Java\n\n\n static final int MAX_REQUEST_BYTES = 10_484_504;\n\n ... (code to get the request object)\n\n int sizeInBytes = request.getSerializedSize();\n\n ### Python\n\n\n from google.ads.googleads.client import GoogleAdsClient\n\n MAX_REQUEST_BYTES = 10484504\n\n ... (code to get the request object)\n\n size_in_bytes = request._pb.ByteSize()\n\n ### Ruby\n\n\n require 'google/ads/google_ads'\n\n MAX_REQUEST_BYTES = 10484504\n\n ... (code to get the request object)\n\n size_in_bytes = request.to_proto.bytesize\n\n ### PHP\n\n\n use Google\\Ads\\GoogleAds\\V16\\Resources\\Campaign;\n\n const MAX_REQUEST_BYTES = 10484504;\n\n ... (code to get the request object)\n\n $size_in_bytes = $campaign-\u003ebyteSize() . PHP_EOL;\n\n ### .NET\n\n\n using Google.Protobuf;\n const int MAX_REQUEST_BYTES = 10484504;\n\n ... (code to get the request object)\n\n int sizeInBytes = request.ToByteArray().Length;\n\n ### Perl\n\n\n use Devel::Size qw(total_size);\n use constant MAX_REQUEST_BYTES =\u003e 10484504;\n\n ... (code to get the request object)\n\n my $size_in_bytes = total_size($request);"]]