I have created an endpoint with plumber (plumber_1.1.0) that generates and returns a data.frame with 400 rows and 35k columns of numeric values which corresponds to a tab-delimited file of 243MB. When I query this endpoint, e.g. on the commad line with wget and curl, it takes around 7 seconds until the download starts. However, the endpoint function itself is finished after around 1 second as measured with system.time. I am wondering where the 6 seconds come from. If it can be attributed to the serialization to tsv it feels like it is a rather bad implementation then.
plumber.R
#* @get /test
function( res){
res$serializer = serializer_tsv()
result = data.frame()
time = system.time({
result = data.frame(replicate(400, runif(35000, min=0, max=100)))
})
print(time)
res = result
}
Thank you @meztez. At least now it is clear what the main issue is. However it seems that plumber produces some overhead and I am not sure were it is coming from. On my server readr::format_tsv takes around 4.3 seconds which doesn't add up to the 7 seconds for the above example. I have also seen that for other examples.