Troubleshooting Memory Allocation Issues in Deployed Plumber API with Large Datasets"

27 views Asked by At

I have previously inquired about this issue without obtaining a solution. To provide more details in the hope of resolving the problem:

I have developed a Plumber API that is deployed on a private server. This API receives data, which is then utilized to generate a report using an R Markdown (RMD) file. The sequence of events involves the API receiving data, invoking the RMD file, the RMD file utilizing the data, and ultimately generating the report.

When running this Plumber API locally, I encounter no issues, regardless of whether the dataset is large or small. However, the API deployed on the server seems to struggle when handling substantial datasets. The specific error message is as follows:

output file: rapport_.knit.md

/usr/bin/pandoc +RTS -K512m -RTS rapport_.knit.md --to docx --from markdown+autolink_bare_uris+tex_math_single_backslash --output /app/rapport_.docx --lua-filter /usr/local/lib/R/site-library/rmarkdown/rmarkdown/lua/pagebreak.lua --table-of-contents --toc-depth 3 --highlight-style tango --reference-doc tmplt.docx
Killed
<simpleError: pandoc document conversion failed with error 137>

This issue does not manifest locally; I run the same code with the same data, and the report is successfully generated.

Upon further investigation, I came across a few posts suggesting a solution involving the use of pandoc_args, such as in the discussions found here https://github.com/rstudio/rmarkdown/issues/315 and here https://stat.ethz.ch/pipermail/r-help/2015-August/431647.html and here as well How to increase stack space overflow for pandoc in R? .

In response, I updated my RMD file to include the following YAML front matter:

---
date: "`r format(Sys.Date(), 'Version du %d %B %Y', locale = 'fr_FR')`"
title: "Rapport"
output:
  officedown::rdocx_document:
    toc: TRUE
    pandoc_args: [
      "+RTS", "-K1G",
      "-RTS"
    ]
---

Despite these changes, when calling my RMD file using rmarkdown::render("rapport_.Rmd"), the memory allocation remains at +RTS -K512m -RTS, although it is intended to be "-K1G" now.

Any insights on how to address this issue would be greatly appreciated.

0

There are 0 answers