How to handle throttling when using the Azure Translator Text API? - microsoft-cognitive

When I send too many request to the Azure Translator Text API I sometimes receive 429 Responses from the API without indication how to properly throttle the request count. I have found some documentation about throttling but it doesn't seem to apply to this specific API: https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits
Does anybody know if there is a similar way to get the remaining request count or the time to wait before another request should be made? Or do I have to implement my own logic to handle throttling?

Azure Translator Text API is bit specific because the limit announced is not around the number of requests but the number of characters.
As mentioned in the documentation here, the limit depends on the type of key:
Tier / Character limit
F0: 2 million characters per hour
S1: 40 million characters per hour
S2: 40 million characters per hour
S3: 120 million characters per hour
S4: 200 million characters per hour
And I guess that there is also a (more technical) requests limit, not clearly indicated in the documentation

To be clear here the limit of microsoft translator for free tier (F0)
2,000,000 million characters per hour/month
33,300 characters per minute
10,000 characters per second/request
limit reset 60 seconds after blocked.

Related

HERE API rate limit header explanation

I am using the route matching HERE api.
At some point due to the large number of requests I receive a 429 error with the following headers.
X-Ratelimit-Limit:[250, 250;w=10]
X-Ratelimit-Reset:[6]
Retry-After:[6]
These are the only rate limiting related headers I receive.
I would like an explanation of the X-Ratelimit-Limit:[250, 250;w=10] header.
What does the 250 and w=10 mean?
The first number is the number of requests that you have made for the given API in the time frame.
The second section refers to the quota policy.
An example policy of 100 quota-units per minute.
100;window=60
For the current example it specifies 250 requests every 10 seconds
More details at : RFC for rate limit header

What are the actual API limits?

On the Stackdriver Trace documentation (https://cloud.google.com/trace/docs/quotas) I see there are Quota unit cost per API call, but that doesn't really tell me what the true API limits are.
For something like BatchWriteSpans the unit cost is 1, but it doesn't tell me how many or how large can my Spans be.
I would like to get more insight into the limits of the API and if there is anyway I can pull this information so that I don't have to hardcode these limits in my app.
The "unit cost" is just telling you how many of request-per-second quota units are used each request. As BatchWriteSpans has cost 1, you can make 4800 BatchWriteSpans each minute.
Below that are the limit on what can be in a request. For example, each span can only have 32 labels, each of which can be at most 128 bytes key and 256 bytes value.
There is no documented limit on the number of spans in BatchWriteSpans, but I'd assume it is the same as PatchTraces, ie 25000.

Alexa Skill Kit 24 Kilobyte Response Limit Change

In the Amazon Alexa developer docs it states that there is a 24 kilobyte limit on the size of the response JSON payload. I previously observed this limit being enforced but recently it seems the limit has been removed.
Does anyone know if this limit officially been removed and if so is there a new higher limit to the response size?
I'm quoting straight from the documentation:
Note the following size limitations for the response:
The outputSpeech response cannot exceed 8000 characters.
All of the text included in a card cannot exceed 8000 characters. This includes the title, content, text, and image URLs.
An image URL (smallImageUrl or largeImageUrl) cannot exceed 2000 characters.
The token included in an audioItem.stream for the AudioPlayer.Play directive cannot exceed 1024 characters.
The url included in an audioItem.stream for the AudioPlayer.Play directive cannot exceed 8000 characters.
The total size of your response cannot exceed 24 kilobytes.
If your response exceeds these limits, the Alexa service returns an error.
So, the limit you are asking is still valid.

Saving firebase bandwidth by shortening field names?

Using Firebase I'm giving the fields easily human-readable names, such as "timestamp", "last_changed", "message_direction" etc.
Are the field names part of the data exchange for every single "row"?
Meaning, would I save bandwidth by shortening the field names?
As Frank pointed out: Yes, they do affect bandwidth. However, if you do the math, you'll see that bandwidth is rarely worth the effort and obfuscation, and that generally your data payload will vastly eclipse the few extra characters of the keys.
Let's consider an average chat message:
{
"sender": "typicaluserid:12345678901234567890",
"timestamp": 1410193850266,
"message": "Hello world. All your base are belong to us!"
}
Okay, so first let's look at the payload for this message. This is 163 bytes, UTF-8 encoded. if I changed the keys to meaningless three character ids (e.g. sdr, ts, and msg), then it would be 149 bytes. With some liberal padding for transaction overhead, let's say about 40 bytes, it's about a 2% savings, in exchange for needing a rosetta stone to read my data.
Next, let's consider bandwidth usage. If we have a very active, very massive chat system (i.e. we're raking in serious $$), we might have 10k active users sending an average of 50 messages per day. That means we'd be sending 200 bytes * 500k = 100MB of data per day, or around 3GB of data per month.
That means that I could support a massive chat system comfortably on Firebase's free plan without exceeding bandwidth limits.
If we take those 11 bytes, off, we have 189 * 500k * 30 = 2.8GB. So not a significant difference for the effort.
My few cents for the sake of "lateral thinking" and "stating the obvious" : sometimes the shortening can have benefits other than bandwidth. For example readability, easier to type, less likely to make a typo, etc.
I recommend spending some time on finding the most concise names that would still be understandable.
/ MrObvious out

Google Translation API

Has anyone used Google translation API ? What is the max length limit for using it?
The limit was 500... now it is 5000 chars.
source
500 characters
source
At the moment, the throttle limit is 100,000 characters per day. Looks like you can apply to have that limit increased/removed.
I've used it to translate Japanese to English.
I don't believe the 500 char limit is true if you use http://code.google.com/p/jquery-translate/, but one thing that is true is you're restricted as to the number of requests you can make within a certain period of time. They also try to detect whether or not you're sending a lot of requests with a similar period, almost like a mini "denial of service" attack.
So when I did this I wrote a client with a random length sleep between requests. I also ran it on a grid so all the requests didn't come from a single IP address.
I had to translate ~2000 Java messages from a resource bundle from Japanese to English. It worked out pretty nicely, as long as the text was single words. Longer phrases with context came out awkwardly.
Please have look at this link it will give the correct answer at the bottom of the page.
https://developers.google.com/translate/v2/faq
What is the maximum number of characters per request?
The maximum size of each text to be translated is 5000 characters, not including any HTML tags.
You can send source strings of up to 5,000 characters, but there are a
few provisos that are sometimes lost.
You can only send the 5,000 characters via the POST method.
If you use GET method, you are limited to 2,000-character length limit on urls. If a url is longer than that, Google's servers will just reject it.
Note: 2,000-character limit including the path and the rest
of the query string as well + you must count uri encoding (for instance every space becomes a %20, every quotation
mark a %22)
The Cloud Translation API is optimized for translating of smaller requests. The recommended maximum length for each request is 5K characters (code points). However, the more characters that you include, the higher the response latency. For Cloud Translation - Advanced, the maximum number of code points for a single request is 30K. Cloud Translation - Basic has a maximum request size of 100K bytes.
https://cloud.google.com/translate/quotas

Resources