aptly-dev / aptly

aptly - Debian repository management tool
https://www.aptly.info/
MIT License
2.56k stars 374 forks source link

REST api timing out when publish takes longer than 1 min #1204

Closed AlexReimann closed 3 months ago

AlexReimann commented 1 year ago

We are running aptly with a local repository and are using the REST api to trigger publishing. We are currently doing a stress test of our setup and the publishing time increases with the number of packages. Once the publishing time increases to > 1min, the REST call fails with curl: (22) The requested URL returned error: 504

Detailed Description

Our test repo has around 23K packages, so the publishing takes quite a while. We already turned of content publishing of the packages (see https://github.com/aptly-dev/aptly/issues/421), which moved the critical number of packages before we get a 504 from the http server from 15k to 23k.

Using the command line the publishing still works fine at that point.

Is there a way to set the timeout for the REST api server?

Context

We could do some workaround, e. g. calling the command line via ssh instead, but I think in general it makes sense that the REST api also works with large number of packages.

Possible Implementation

Expose the (timeout) settings for the api http server.

reglim commented 1 year ago

Thank you for submitting this issue. I tried, but I couldn't reproduce this locally. I set up a snapshot with several gigabytes of data and I didn't get a timeout locally through curl with the following command:

$ time curl -X POST http://localhost:8080/api/publish    -H 'Content-Type: application/json' -d '{
"SourceKind": "snapshot",
"Sources": [
{
"Name": "bullseye-snap"
}
],
"Signing": {
"Skip": true
}
}'
^C

real    2m23.659s
user    0m0.010s
sys 0m0.000s

Could you add some detail as to whether you're using some kind of nginx proxy or anything in that direction?

AlexReimann commented 1 year ago

We have a traefik reverse proxy in between, but even using the command line the publishing in this case takes > 1min, so I think it is independent from the network setup.

It might be just that the disk we are using is slower (network drive), so it takes longer. Or the publishing time is more related to the number of packages (as stated above 15k+ packages), than the size. The size in our case was actually "rather small" (< 15 GB).

Our workaround so far is to have the publishing done with ?_async=true (taken from here https://github.com/aptly-dev/aptly/issues/1125), but with this we don't get error codes back when the publishing goes wrong.

reglim commented 1 year ago

What I thought could be the issue, is that the connection is being timed out by your proxy and not the API. Is is possible to check by connecting via ssh (or just connect without the proxy) and curl-ing from there?

AlexReimann commented 1 year ago

Yeah, just tried it locally without anything in between. Currently takes around 30 secs as we recently wiped the repo, so it is not timing out yet.

I can do a test setup with more packages to see if it then times out eventually, though maybe I'll just wait a week or two till we reached the amount of packages again :sweat_smile:

reglim commented 1 year ago

Ok, perfect. I'll be interested to hear if it worked.