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

Max memory and restart windows server #121

Open
PhamHuyThien opened this issue Jan 29, 2024 · 4 comments · May be fixed by #141
Open

Max memory and restart windows server #121

PhamHuyThien opened this issue Jan 29, 2024 · 4 comments · May be fixed by #141

Comments

@PhamHuyThien
Copy link

Hello I am currently having some major problems using it

After starting the system for about 1 hour - 2 hours, RAM usage suddenly increases to 90% and restarts the server
Currently, I have used PM2 and rebooted every hour but the RAM is still at 90%.

My device configuration:
Windows server 2016
RAM: 16GB
CPU: 8 cores
400GB SSD

my source:

async investing(body = {
        type: 'klines/realtime',
        name: '', //https://github.com/DavideViolante/investing-com-api/blob/master/mapping.js
        period: 'P1D, P1W, P1M, P3M, P6M, P1Y, P5Y, MAX',
        interval: 'PT1M, PT5M, PT15M, PT30M, PT1H, PT5H, P1D, P1W, P1M',
        pointcount: '60, 70, 120',
        pptrLaunchOptions: undefined,
    }) {
        let response = await investing(body.name, body.period, body.interval, Number(body.pointcount), body.pptrLaunchOptions);
        return ....
    },

Looking forward to receiving comments.

@PhamHuyThien
Copy link
Author

https://github.com/PhamHuyThien/investing-com-api-v2

I forked the project and upgraded to version V2.0
Fix error: RAM memory overflow

@DavideViolante
Copy link
Owner

Hello, can you elaborate more how did you fix your problem, for future users? Is there a memory leak in my repo?

@PhamHuyThien
Copy link
Author

Hello, can you elaborate more how did you fix your problem, for future users? Is there a memory leak in my repo?

Hello author,

Not receiving a response from you, I think I have to solve this problem myself.
According to my investigation, closing the browser every time the API is called causes a big problem, sometimes 'puppeteer' cannot close itself (when making multiple calls in a row) the chromium windows stay active, stopping the project also does not solve the problem
The way I solved it is instead of starting puppeteer continuously I just open a browser and open multiple tabs and end it each time I'm done working.
I tested opening/closing 200 tabs continuously for 3 hours, the number of suspended tabs was very small (+-5 tabs).

Use my version 2 or upgrade your project, better experience.

End :)

@PhamHuyThien PhamHuyThien reopened this Feb 25, 2024
@liardoecp
Copy link
Contributor

liardoecp commented Oct 19, 2024

Hi everyone,

i was wondering if puppeteer is really necessary. I forked this repo and replaced puppeteer with fetch. It's seems works very well and the performance are better.

Here my PR: #141

Benchmark

Code

const run = async () => {
    const iterations = 10
    const responsesTime = []

    for (let index = 0; index < iterations; index++) {
        const start = new Date()
        await investing('1')
        responsesTime.push(new Date() - start)
        console.log(`run ${index + 1}: ${responsesTime[index]}ms`)
    }
    const avg = responsesTime.reduce((acc, responseTime) => acc + responseTime, 0) / responsesTime.length
    console.log(`avg: ${avg}ms`)
}

Results

With puppeteer

run 1: 1132ms
run 2: 3223ms
run 3: 1433ms
run 4: 1612ms
run 5: 1088ms
run 6: 1833ms
run 7: 1367ms
run 8: 1674ms
run 9: 1715ms
run 10: 1540ms
avg: 1661.7ms

With fetch

run 1: 371ms
run 2: 170ms
run 3: 139ms
run 4: 150ms
run 5: 138ms
run 6: 159ms
run 7: 170ms
run 8: 154ms
run 9: 164ms
run 10: 133ms
avg: 174.8ms

@liardoecp liardoecp linked a pull request Oct 20, 2024 that will close this issue
liardoecp added a commit to liardoecp/investing-com-api that referenced this issue Oct 21, 2024
liardoecp added a commit to liardoecp/investing-com-api that referenced this issue Oct 21, 2024
liardoecp added a commit to liardoecp/investing-com-api that referenced this issue Oct 21, 2024
liardoecp added a commit to liardoecp/investing-com-api that referenced this issue Oct 21, 2024
liardoecp added a commit to liardoecp/investing-com-api that referenced this issue Oct 21, 2024
liardoecp added a commit to liardoecp/investing-com-api that referenced this issue Oct 22, 2024
liardoecp added a commit to liardoecp/investing-com-api that referenced this issue Oct 22, 2024
liardoecp added a commit to liardoecp/investing-com-api that referenced this issue Oct 22, 2024
liardoecp added a commit to liardoecp/investing-com-api that referenced this issue Oct 22, 2024
liardoecp added a commit to liardoecp/investing-com-api that referenced this issue Oct 22, 2024
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

Successfully merging a pull request may close this issue.

3 participants