Comments (10)
I've just took a look at this old code and it seems so.
As you suggest, the correct solution should be 1 connection kept-alive and per host per thread.
I'll ping you for a review of the new code soon :)
from rmega.
Some testing says that there's nothing that breaks if using a per-thread connection pool (technically per-fiber, using Thread.current
) but there is another issue stopping that from doing anything: Pool creates a new thread for every single chunk, rather than keeping threads alive for as long as possible.
Modifying Pool so that threads live until they run out of work, only creating new threads up to the limit seems to work fine. but that reveals another issue: there's no coherent place to call 'finish' for HTTP requests. It would require quite a bit more "upwards visibility" in the network stack, or an open/close interface in Net (what I'm about to try)
from rmega.
tested adding an http_wrap
method in Net, and wrapping the each_chunk
in it. Opens a connection to the storage server even if one may not be needed, but it seems to work? it's at least re-using the HTTP objects. Another possible (albeit hacky) solution is to simply keep all userstorage.mega.co.nz
connections open for the lifetime of the thread, and let the GC close them.
from rmega.
Just tested a dirty workaround (let the GC close the userstorage connections for us), can confirm persistent connections make a huge difference in speed. it's now capable of hitting 100Mbps on 4 threads.
from rmega.
checkout this new branch https://github.com/topac/rmega/tree/conn_pool
from rmega.
@baconwaifu have you tried using the changes from the conn_pool branch?
from rmega.
from rmega.
using Typhoeus instead of plain net/http should work. Typhoeus already handles http connection pooling
from rmega.
@vijayanandnandam sure but I would like to not have dependencies on other gems
from rmega.
this was merged
from rmega.
Related Issues (20)
- about app api keys and sessions HOT 4
- How to do storage HOT 1
- Excessively slow aes_cbc_mac function HOT 1
- ERROR: end of file reached, rmega-up command HOT 2
- Unable to allocate space for file HOT 1
- Error Message when Quota of Plan Exceeded is "ERROR: Unexpected Length" HOT 9
- Command issue HOT 3
- Folder Supported?
- The upload target URL you are trying to access has expired. Please request a fresh one. (Rmega::ServerError) HOT 5
- ERROR: File exists @ dir_s_mkdir
- ERROR: No such file or directory @ rb_file_s_size HOT 2
- Link file handling HOT 1
- Checksum error
- skip empty data HOT 2
- ERROR: Protocol error @ dir_s_mkdir HOT 3
- upload failure: block length incorrect HOT 4
- I need help! How to solve this? HOT 1
- Be able to upload a folder with its content HOT 3
- ERROR: `read_configuration_file': undefined method `exists?' for File:Class (NoMethodError)` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rmega.