Похожие чаты

Hello Everyone! What could you recommend, I need to execute

near to couple of thousands requests to API and I need to make it robust and effective, what shuuld I avoid doing? Does okhttp library fits to my case or should I consider using something else?
Thanks

7 ответов

23 просмотра

Few things I can think of right away: - rate limiting. If it's 3rd party API, then most likely it is rate limited. Learn all the limits of the API, and tune your code to not spam it with requests. - prepare for failure. Think of what you should do if your recive non-200s. It greatly depends on what exactly you're developing. Typical approaches to start with: — "circuit breaker", basically means "if it failed several times in a row, stop spamming it, give it some time, and continue later" — "retry" (usually with some backoff strategy, typical one is "exponential backoff"), means "if it failed, retry a little bit later" - depending on what you're developing, if your app may stop/restart/get killed/etc., and after restart you need to continue from the last successful call, you'll need to persist state. Depending on what you're developing, it may be a simple file, or it may be a record in DB, whatever is easier.

Dmytro Buryak
Few things I can think of right away: - rate limi...

Thank you for the advices! Rate limit is already one of the things that I have caught 😅

Doesn't Java have a built-in HTTP client at java.net.http?

Edwing123
Doesn't Java have a built-in HTTP client at java.n...

Yes, it does, but I have adopted the project from other developer. It already had code with okhttp library used. I have a controller that receives some parameters, after that in the service layer I'm sending info according to the input to 3rd party API. Everything works ok once program receives only 1 request, but with multiple requests it's getting weird behavior where requests starting not get response at all, and one other parts of service layer is POST uploading of files to AWS S3 is where I found the request rate limit.

Edwing123
Doesn't Java have a built-in HTTP client at java.n...

The built-in http client is way too basic, and hard to use. You need too much boilerplate to just send a post request. Plus it's synchronous. It's fine for simple tasks, but for making http requests routinely it's not a good fit.

Любомир Приймак 🇺🇦
Yes, it does, but I have adopted the project from ...

Sounds like concurrency issues. If you shared some code, I believe I could help

Dmytro Buryak
Sounds like concurrency issues. If you shared some...

I found the problem later in the day, it again was a request rate limit. The API I'm communicating with just handles that in a weird way, not like AWS, that's why it was confusing to me and I was assuming that it could be some concurrency things. But anyways thank you for the response

Похожие вопросы

Обсуждают сегодня

а через ESC-код ?
Alexey Kulakov
29
30500 за редактор? )
Владимир
47
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
Чёт не понял, я ж правильной функцией воспользовался чтобы вывести отладочную информацию? но что-то она не ловится
notme
18
Привет)) уже кажется эту тему перемусолили, но вот я так и не понял. Я сейчас сижу на 27дюймов 2к мониторе. На Актуальной макоси, если я куплю 27д 4к монитор: - будет ли изобр...
Vladislav Piskunov
15
Hi guys, any problem with Pulsebrige? Trying to transfer from wETH to ETH. First it tells me to connect my metamask "through mobile app" not desktop. Then I did and confirmed ...
Snowflakecrypto
13
any reference of this implementation?
BitBuddha
29
У меня есть функция где происходит это: write_bit(buffer, 1); write_bit(buffer, 0); write_bit(buffer, 1); write_bit(buffer, 1); write_bit(buffer, 1); w...
~
13
Страшнейшая правда про списки ЦБ. С первых дней жизни P2P сферы, молодые человеки, начитавшись законодательной базы и "внутренних" документов, решили, что им противостоит сер...
Foxcool
3
&"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.42.34433\bin\Hostx64\x64\dumpbin.exe" /EXPORTS C:\Users\Yeet\Tauon\vcpkg\installed\x64-window...
Martin Rys
6
Карта сайта