Похожие чаты

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 ответов

26 просмотров

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

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

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

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта