Git Product home page Git Product logo

Comments (1)

csaltos avatar csaltos commented on August 15, 2024

The values depends on your case, the size of servers, the number of connections and a lot of factors, normally you start with some conservative numbers and then you test the performance of your system an tune accordingly.

As a reference this is the configuration we are using at my company:

import com.twitter.conversions.DurationOps._
import com.twitter.finagle.Backoff
import com.twitter.finagle.Http
import com.twitter.finagle.ServiceFactory
import com.twitter.finagle.http
import com.twitter.finagle.service.ReqRep
import com.twitter.finagle.service.ResponseClass
import com.twitter.finagle.service.ResponseClassifier
import com.twitter.finagle.service.RetryBudget
import com.twitter.util.Duration
import com.twitter.util.Future
import com.twitter.util.Return
import com.twitter.util.StorageUnit
import com.twitter.util.Timer

val host = "test.com"
val url = "https://test.com/test1"
val totalRequestTimeout = 5.seconds
val referenceTimeout =
    Duration.fromMilliseconds(
      Math.max(1L, totalRequestTimeout.inMillis / 5L - 100L)
    )
initialRequestTimeout =
    Duration.fromMilliseconds(referenceTimeout.inMillis * 2L)
val retryRequestTimeout =
    Duration.fromMilliseconds(referenceTimeout.inMillis * 3L)
val maxResponseSizeInBytes = 10000000
val clientFactory = Http.client
      .withRequestTimeout(initialRequestTimeout)
      .withRetryBudget(RetryBudget())
      .withRetryBackoff(Backoff.exponentialJittered(1.second, backoff))
      .withResponseClassifier(
        customResponseClassifierOnErrors orElse http.service.HttpResponseClassifier.ServerErrorsAsFailures
      )
      .withMaxResponseSize(
          StorageUnit.fromBytes(maxResponseSizeInBytes)
        )
      .withTls(host)
val client = clientFactory.newClient("test.com:443")
val requestBuilder = http
      .RequestBuilder()
      .url(url)
      .addHeader(
        http.Fields.UserAgent,
        "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:50.0) Gecko/20100101 Firefox/50.0"
      ).addHeader(http.Fields.Host, host)

val request = requestBuilder.buildGet()
val response = httpClient.toResponse(request)
response

from finagle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.