1

I am currently utilizing an excel parser library called XLSX

I have to parse large size excel file and the problem is that XLSX only supports synchronous readFile request. So when multiple http requests are made, the XLSX reading function blocks the other requests making user experience very bad. I am currently using expressJS as my framework. Is there a way of making the function asynchronous instead of having to change the excel reading library?

Thanks

2
  • 1
    It's worth pointing out that you have other parser options besides xlsx. If you want an async version, try excel, it handles xlsx files asynchronously. Commented Aug 8, 2017 at 2:56
  • @Paul Thank you. I'll look into that too Commented Aug 8, 2017 at 3:34

1 Answer 1

3

I only know of three choices:

  1. Rewrite the XLSX library to use asynchronous I/O.
  2. Create a work queue and several child processes and run the XLSX work in child processes only.
  3. Pick a different library that uses async I/O.

There is no way to make a function that uses synchronous I/O magically become async without rewriting it or moving it to another process.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. the second choice looks to be a good method, otherwise third. Is there anything that I should be aware of if I decide to spawn a new read process every time new request is made?
@serendipity - You probably want to put a cap on the number of processes you open and use a queue if there isn't a worker process ready. This prevents a DOS attack by causing you to create too many processes.
Thanks I'll make sure of that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.