finaglehelper on develop
finagle-http: Remove expensive … (compare)
finaglehelper on develop
Revert "finagle-core: return an… (compare)
finaglehelper on develop
finagle-core: Deprecate Legacy … (compare)
finaglehelper on develop
finagle-core: Add `CertsAndKey`… (compare)
finaglehelper on develop
finagle-core: return an empty b… (compare)
Hi .. I am new to Finagle and I am using it in my java service. However, I am facing some problem while implementing retries in case of certain HTTP Error codes. The retry policy shouldRetry function does not gets called in case of request failing with certain error codes
here is the snippet of the code i am using to instantiate the client
private Service<Request, Response> buildClient(String host) throws Exception {
String hostString = String.format("%s:%s", host, "8080");
PartialFunction<Tuple2<Request, Response>, ResponseClass> typed =
new AbstractPartialFunction<Tuple2<Request, Response>, ResponseClass>() {
@Override
public boolean isDefinedAt(Tuple2<Request, Response> x) {
return x._2().status() == Status.InternalServerError() || x._2().status() == Status.ServiceUnavailable();
return true;
}
@Override
public ResponseClass apply(Tuple2<Request, Response> x) {
return ResponseClass.RetryableFailure();
}
};
return this.hostToClientMap.computeIfAbsent(host, s -> {
try {
return ClientBuilder.safeBuild(
ClientBuilder.get()
.stack(Http.client())
.hosts(hostString)
.hostConnectionLimit(serviceConfiguration.getHttp_max_conn_per_route())
.tcpConnectTimeout(Duration.fromMilliseconds(serviceConfiguration.getHttp_socket_timeout_in_ms()))
.keepAlive(true)
.tls(LogDispatcherFactory.buildSslContext(serviceConfiguration.getSsm_store_region(),
serviceConfiguration.getPrism_certificate_path(),
serviceConfiguration.getPrism_certificate_key_path(),
serviceConfiguration.getTruststore_password()))
.connectTimeout(Duration.fromMilliseconds(serviceConfiguration.getHttp_connect_timeout_in_ms()))
.requestTimeout(Duration.fromMilliseconds(serviceConfiguration.getHttp_request_timeout_in_ms()))
.retryPolicy(new CustomRetryPolicy())
.retryBudget(RetryBudgets.newRetryBudget(Duration.fromSeconds(10), 10, 1))
.failFast(false)
.responseClassifier(HttpResponseClassifier.apply(typed))
.reportTo(DefaultStatsReceiver.get()));
} catch (Exception e) {
logger.error(String.format("Error initializing the finagle client for host %s.", hostString), e);
return null;
}
});
}
Any thoughts on this ???
Hi!
I have some performance questions regarding Finagle. I understand that you should not do any CPU bound operation on Finagle threads and that you should offload I/O work to FuturePool. But checking the comment in FuturePool it states, that this Pool should mainly be used in I/O operations and that CPU-bound operations need some special treatment. Is there any documentation about this "special treatment"?
We currently have a Finagle server, that gets some data from the hash map, but if this data is not found in hashmap, we do a quite expensive regex parsing. Since regex is CPU bound and we are using FuturePool.unboundedPool
, we ofter starve out the whole thread pool and our Finagle server becomes unresponsive. Is there any standard way to approach it? I was thinking that this regex parsing should only get a bounded future pool, for example 6 threads, so if there are a lot of cache misses, we should limit the blast radius, by only hogging 6 threads. Would this approach be viable? Or are there any other ways to check it? Should we downsize Finagle event loop threads to avoid hogging?
Thanks
Hey!
Is it possible to disable finagle's tracing for a given http request after it has already been selected
for sampling? I'm looking for something like c.t.f.tracing.Trace.cancelSampling()
which I can call in my http handler.
Usecase: We have an http server with fairly low RPS and thus a high sampling rate.
We now want to exclude all healthcheck requests from tracing though since they are high in volume
and not needed (they cannot be extracted to an admin http server or similar for various reasons)
Cheers
@dziemba You can adjust the sampled
flag in of the current trace id.
// in handler
Trace.letIdOption(Trace.idOption.map(id => id.copy(_sampled = Some(false)))) { ... continue the http handler here ... }
This would only prevent the code within the closure from tracing. Depending on where in the stack this closure is placed, some of finagle's default traces could still be emitted. Can you create an GH issue about this? Are you using barebones finagle or finatra for your http server?
Scrooge
but I'd like to know if it is possible to support getting an immutable binary
type such as com.twitter.io.Buf
when generating scala code? The fact that ByteBuffer
is mutable might cause all sorts of trouble if you're not careful. Just copying it without using asReadOnly
changes the underlying position in the array and if you try to protect yourself with read only it can fail in the thrift service with java.nio.ReadOnlyBufferException
. To me it feels like Buf
would be the safer option here, ofc something that can be configurable but please correct me if I'm wrong :)