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

Make buffer size of RedisOutputStream/RedisInputStream configurable #1011

Closed
itugs opened this issue May 29, 2015 · 4 comments
Closed

Make buffer size of RedisOutputStream/RedisInputStream configurable #1011

itugs opened this issue May 29, 2015 · 4 comments
Labels

Comments

@itugs
Copy link
Contributor

itugs commented May 29, 2015

The buffer size of RedisOutput/InputStream is fixed as 8192, 8KB.
It is no problem if there is not much connection.

In our case, we maintain many connections concurrently and handle under 1KB.
So 8KB is too big for us, and became burden of OldGen.

RedisOutputStream/RedisInputStream already has configurable constructor but in Connection#connect there is no chance to use it.

  • Connection#connect
  public void connect() {
    if (!isConnected()) {
      try {
        socket = new Socket();
        // ->@wjw_add
        socket.setReuseAddress(true);
        socket.setKeepAlive(true); // Will monitor the TCP connection is
        // valid
        socket.setTcpNoDelay(true); // Socket buffer Whetherclosed, to
        // ensure timely delivery of data
        socket.setSoLinger(true, 0); // Control calls close () method,
        // the underlying socket is closed
        // immediately
        // <-@wjw_add

        socket.connect(new InetSocketAddress(host, port), connectionTimeout);
        socket.setSoTimeout(soTimeout);
        outputStream = new RedisOutputStream(socket.getOutputStream());
        inputStream = new RedisInputStream(socket.getInputStream());
      } catch (IOException ex) {
        broken = true;
        throw new JedisConnectionException(ex);
      }
    }
  }
@marcosnils
Copy link
Contributor

@itugs makes sense. I'm thinking of the proper way of setting buffer size without adding a new constructor to all Jedis instances (Pool / Cluster / Sharded / etc) but I can't come up with a solution.

Any sugestions?

@marcosnils
Copy link
Contributor

@itugs another question: Would it make sense to modify this value on runtime?. Maybe we can do something like. jedis.getClient().setIOBuffer().
I'd guess that modifying that value in runtime might probably cause errors, right?

@itugs
Copy link
Contributor Author

itugs commented May 29, 2015

@marcosnils Runtim modification will work if it is properly handled. ie, isolate modification with communication. But IMO construction time configuration is preferred for simplicity and clarity.

I'm also checked but it is not easy if we do not add new constructors at classes.
IMO ideally it's is good to introduce configuration object like ConnectionConfig.

Copy link

This issue is marked stale. It will be closed in 30 days if it is not updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants