Похожие чаты

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

13 просмотров

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

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

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

я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
100
в сях есть множество как в питоне? для удаление дубликатов
Linus
25
Hi everyone, long time no see! 🐼 recently i want to update our Ergo Eco-System map, can everyone help to find out, which to delete and other new to add in? list it, that i can...
HEROKOO
13
This topic is discussed al lot. Please use the search function for the answers. The same question pops up every two weeks. First check this video https://www.youtube.com/watch...
Enrico
2
зеленые ноты вижу, а коричневые?
οἰφέω σκάπτω
19
If arrr gets implemented on cake wallet. Would that mean arrr/xmr swaps possible in cake wallet like atomic swaps on komodowallet ?
Keks Meister 🏴‍☠️
22
читать файл максимально быстро? странный вопрос))
zamtmn
53
Yeh scammer hai kya ? 🙄 mujhre bhi solana invest ke liye bol re thi kal
Amit
18
30 BCH videos in Hausa Language successfully delivered. In December 2023, I created a Flipstarter to produce Bitcoin Cash videos in the Hausa language for greater outreach an...
Munnir
9
Я хочу запустить свой проект в тг. Что-то между пирамидой и майнилкой. Еще подобного ничего не было. Уникальная идея. Нужен именно не бот, а приложение. С ввод, выводом тон...
Павел А.
6
Карта сайта