how to get bandwith consumption in yii2 per request - yii2

How can I get the bandwidth consumption of user per request in yii2?
I tried afteraction and beforeaction in \yii\web\Controller but I don't get it.

Related

Bim360 api - 429 - too many requests

We have desktop and mobile app (2 different client id) integrated with bim360 api. We have a problem with 429 error responses. Documentation: https://forge.autodesk.com/en/docs/data/v2/developers_guide/rate-limiting/ doesn't give us a lot of details.
How does it work? How can we avoid it?
What will happen if 1000 different users from apps with the same client_id at once try to get issues list? Will it be distinguish as Ddos? Are hubId, projectId, user account, ip address considered in rate-limiting algorithm?
As I know, each API has a well-configured rate-limit per minute per client id. After reaching the limit, you will see a retry-After parameter appears in the response header of each of your API call. It stands for the retry time when you can call the API again, and the unit of this value is in second. You can schedule a retry task along this retry time in your code.
Note. The value of the retry-After will reset if you make another call before reaching the Retry-After duration.
Hope it help, Cheers!

Viber REST API[GATEWAY_TIMEOUT]

I am making REST API call to Viber back-end but intermittently I am getting 504 GATEWAY_TIMEOUT error.
Are there any limitations when we send multiple requests to Viber back-end at the same time?
Yes, they have limitations. See Broadcast Message section.
Maximum total JSON size of the request is 30kb. The maximum list
length is 300 receivers. The Broadcast API is used to send messages to
multiple recipients with a rate limit of 500 requests in a 10 seconds
window.

Calculating the amount of data (bytes) a user using

We are a subscription based platform that charges per data used. How do we calculate the total amount of data used by 'get' and 'post' requests by a user? Also, how can we calculate the HTTP request size?
As we are using AWS does AWS have some mechanism or service to calculate our user data usage for us?

Google Place Reviews API - Photos return 403 on pageload

I'm currently using the Google Places API to pull reviews onto a webpage. Everything is working fine except for the Photos of the people leaving reviews. When trying to get the photo of the reviewer, it's returning a 403 Forbidden on every other page load. It seems that there might be a rate limit perhaps?
The problem is I can't find any documentation about rate limits and how to get the picture to display without issue. Am I missing something in the docs?
My API call is this;
https://maps.googleapis.com/maps/api/place/details/json?placeid=PLACE_ID&key=API_KEY
That returns quite a long JSON array (I've cut it down). One of those fields is;
{
"result" : {
"reviews" : [
{
"profile_photo_url" : "//lh5.googleusercontent.com/url/photo.jpg"
}
}
}
}
Like I said, if I refresh a couple of times it'll cause a 403 error for the images get request. Anyway to cache or allow more requests?
I found out why this was happening. It's to do with rate limits on the photo media which is why it was giving a 403 error in the console. The developer docs outline the limits for the media requested.
An excerpt of the docs...
The Google Places API Web Service enforces a default limit of 1,000
free requests per 24 hour period, calculated as the sum of client-side
and server-side requests. If your app exceeds the initial limit, the
app will start failing. You can increase this limit free of charge, up
to 150,000 requests per 24 hour period, by enabling billing on the
Google API Console to verify your identity. A credit card is required
for verification. We ask for your credit card purely to validate your
identity. Your card will not be charged for use of the Google Places
API Web Service.
Best thing to do is to cache the media once it's requested to avoid going over the limit which is especially useful if you're reloading the page lots of times for testing local development changes.

Google Map Services(Places) returning error message "You have exceeded your daily request quota for this API." But I've used it just for a while

I am using Google Maps service (Places, directions). After using for a while I am receiving response :
{ "error_message" : "You have exceeded your daily request quota for this API.", "predictions" : [], "status" : "OVER_QUERY_LIMIT"}.
I found this link Usage limits for services when used with Google Maps Javascript API v3. In this link it is mentioned that "Places API allows 1,000 or 100,000 (if you're verified) requests per 24 hours." But i have not requested it even for 200 times.
Is there some other reason for this response or is there any alternative to get rid of this problem. Thanks in advance.
Usage Limits for Google Maps API Web Services
Yes. There is another possible reason for getting the "Over query" message. And it's a common problem. If you make subsequent query requests too quickly, Google will respond with the over query limit message you posted.
From the Google API spec
Usage limits exceeded
If you exceed the usage limits you will get an OVER_QUERY_LIMIT status code as a response.
This means that the web service will stop providing normal responses and switch to returning only status code OVER_QUERY_LIMIT until more usage is allowed again.
This can happen:
Within a few seconds, if the error was received because your
application sent too many requests per second.
Some time in the next 24 hours, if the error was received because
your application sent too many requests per day. The time of day at
which the daily quota for a service is reset varies between customers
and for each API, and can change over time.
Add delay between requests to eliminate error
You need to insert a delay between requests to the Google Map API to get rid of the message and get the API to respond. How you implement a delay depends upon the platform you're using.