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

How to save receive post files over to the memory #88

Open
andaok opened this issue Mar 11, 2015 · 1 comment
Open

How to save receive post files over to the memory #88

andaok opened this issue Mar 11, 2015 · 1 comment

Comments

@andaok
Copy link

andaok commented Mar 11, 2015

In nginx+lua mode, I use lua_resty_upload to receive post files over, I want to save the received file into memory, then write directly to the distributed file system i.
So less write files to the local hard disk and read files from the local hard disk, reduce I/O, improve the efficiency of.
How to save post files over to the memory, how to achieve this!,

@agentzh
Copy link
Member

agentzh commented Mar 11, 2015

@andaok Hopefully you're not buffering the whole request body at once in memory because that'll be too expensive for large inputs. The recommended way is do non-buffered processing (or streaming processing) such that a (small) constant size of memory is used regardless how big the total stream is.

To be more specific, you can first read a data chunk (say 4KB or 8KB) from lua-resty-upload, and then write it out via cosockets nonblockingly to the backend immediately, and then read the next data chunk and so on.

Hopefully your "distributed file system" exposes a socket endpoint otherwise file IO related syscalls will almost always be blocking.

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