Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High CPU usage when server is idle #786

Closed
Smoovsky opened this issue Feb 23, 2021 · 7 comments
Closed

High CPU usage when server is idle #786

Smoovsky opened this issue Feb 23, 2021 · 7 comments

Comments

@Smoovsky
Copy link

We have been on Enterprise license for a few years, can't remember exactly when this issue started to occur(our jsreport version is always updated to the latest).
CPU usage starts climbing once the jsreport starts and finally occupies all the resources after few days.
A typical usage graph is like this:
image

Here is the jsreport.config.json

{
  "httpPort": 9500,
  "timeout": 30000,
  "templatingEngines": {
    "numberOfWorkers": 4,
    "strategy": "http-server"
  },
  "chrome": {
    "strategy": "chrome-pool",
    "numberOfWorkers": 4
  },
  "store": {
    "provider": "fs"
  },
  "allowLocalFilesAccess": true
}
@pofider
Copy link
Contributor

pofider commented Feb 24, 2021

could you please describe a bit your deployment?
Its an azure VM, or web app? Using docker? What OS?
What jsreport version do you use?
Do you have some jsreport schedules? How many? https://jsreport.net/learn/scheduling
Do you have stored some jsreport reports? How many? https://jsreport.net/learn/reports
Could you share the logs around restart time?

@Smoovsky
Copy link
Author

could you please describe a bit your deployment?
Its an azure VM, or web app? Using docker? What OS?
What jsreport version do you use?
Do you have some jsreport schedules? How many? https://jsreport.net/learn/scheduling
Do you have stored some jsreport reports? How many? https://jsreport.net/learn/reports
Could you share the logs around restart time?

Jsreport is deployed to an Azure VM(D2sV2) with Windows Server 2016 x64.
Jsreport version is 2.11.0.
No schedule was used.
We have 44 templates in the file store, the complexity of each template varies from plain text (~10ms/render) to complicate pdf (~4000ms/render).

It's serving 1000~2000 requests daily, our application indicates no request was failed. The only problem is that each request is getting slower(as jsreport's node.exe is gradually consuming all CPU).

A little bit more details, the jsreport server is launched by npx command:
npx jsreport start --tempDirectory={workDirectory} --rootDirectory={workDirectory}
We have another program that infrequently deploys new templates to jsreport's work directory, it will restart the jsreport process after each template deployment. (It kills all processes that hold a file-handle of jsreport's work directory, including all child processes and chrome.exe spawned by jsreport).

By the way, we have the same application deployed to an Azure VM scaleset which is used to process intensive batch requests. Since the slow-down is not obvious in the case of VMSS, I didn't notice till today it's suffering from the same problem. The usage is not really high but high enough to prevent VMSS to scale down hence the number of instances is maxed out for weeks.
jsreport.log

@pofider
Copy link
Contributor

pofider commented Feb 25, 2021

Thank you, I see you deploy templates and restart jsreport afterward, this means you don't need jsreport to monitor the data folder. It can be the cause of high CPU usage. Could you try to apply this config?

"extensions": {
    "fs-store": {
      "syncModifications": false
    }
}

@Smoovsky
Copy link
Author

Thank you, I see you deploy templates and restart jsreport afterward, this means you don't need jsreport to monitor the data folder. It can be the cause of high CPU usage. Could you try to apply this config?

"extensions": {
    "fs-store": {
      "syncModifications": false
    }
}

We have changed the config, will come back to you after another few days of observation to let you know whether the issue persists.

@Smoovsky
Copy link
Author

Smoovsky commented Mar 3, 2021

Thank you, I see you deploy templates and restart jsreport afterward, this means you don't need jsreport to monitor the data folder. It can be the cause of high CPU usage. Could you try to apply this config?

"extensions": {
    "fs-store": {
      "syncModifications": false
    }
}

It's been 3 days since we changed the config. I can confirm now the issue is gone. But I still reckon it's related to a bug in jsreport.

@Smoovsky
Copy link
Author

Smoovsky commented Mar 8, 2021

Thank you, I see you deploy templates and restart jsreport afterward, this means you don't need jsreport to monitor the data folder. It can be the cause of high CPU usage. Could you try to apply this config?

"extensions": {
    "fs-store": {
      "syncModifications": false
    }
}

It has been a week, no issue ever since we change the config. Shall I close this issue?

@pofider
Copy link
Contributor

pofider commented Mar 8, 2021

Thank you for the update. I'm closing this.

It can be an issue of our external dependency, but it won't be so much a problem in the future anyway, because in the v3 jsreport will default to not use it and it will be only opt-in for development purpose when developer anyway restarts often.

@pofider pofider closed this as completed Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants