On formats and perf

So in terms of raw performance, what is the best format OOTB that doesn’t require attributes on DTO’s?
Is it the new CsvServiceClient?

looking to pick the default for service to service calls on the gateway

CSV is optimal text serializer for tabular data formats, i.e. List<T>. The fastest are the Protobuf and MsgPack binary serializers but Protobuf requires numerical attributes. We don’t have control over these implementations so they’re not very configurable like ServiceStack.Text serializers are.

Otherwise the fastest text serialiser is JSV for normal POCO DTO’s, CSV when tabular. But JSON is not too far behind JSV which is highly interoperable and the fastest way to get it deserialized in Ajax Web Apps - which is basically what I use. There’s some gains in optimizing the serializer but pales in comparison to a good caching strategy which is where I’d prefer to focus on when performance matters.

1 Like

Thanks, think I’ll go with Jsv as the best all rounder then.

1 Like

Just reading the cache aware clients.

So any issue with trying to leverage this by default in the ServiceGatewayFactory with a shared cache dictionary?

// gateway creation delegate
IServiceGateway serviceGateway = defaultGateway(baseUri);
// return if delegate is already using cachedclient
if (serviceGateway is CachedServiceClient) return serviceGateway;

// is http based client, if so, create cached client and use shared internal cache
var serviceClient = serviceGateway as ServiceClientBase;
return serviceClient == null ? serviceGateway : serviceClient.WithCache(sharedCache);

In theory there shouldn’t be, but in practice you’ll be the first to implement it inside a Service Gateway :smile:

But it’s the same as using it on a normal Service Client, note that it only works for GET requests (it just passes the request through for other requests) so you’ll want to annotate your DTO’s with IGet where appropriate, and sprinkle some HTTP Caching on the server to take advantage of it.

1 Like

Surely that would be the concern of the downstream service! :wink:

On that note though, are the IVerb interfaces added to the poco generation code?

Not ready to push any changes yet though, will be another few days, working out the kinks with tagging dto’s in consul with preferred formats, restrictions, secure only and poco versionng so that the gateway will choose and configure the client correctly all on it’s ownsome.

Yeah the IVerb markers have been emitted in Add ServiceStack Reference for a while now, they’re even supported in Swift, Java and Kotlin :slight_smile:

it is such a pleasure to work with this framework :smile:

I find I’m doing a lot of github searching for docs though, are there any means or plans to export github pages into a more doc searchable format, that would be really handy

1 Like

Yeah @layoric is working on a new solution for docs but still has other things higher up on the priority list atm - we’ll get to it eventually.

1 Like

Look forward to it.

On the CachedServiceClient, it doesn’t expose the internal client, is that deliberate?

Only that it shouldn’t be necessary since you’re passing the instance in that it uses, but it’s also not a great idea to provide access to it since it’s delegates are wired to that instance and changing it, e.g. re-assignning the RequestFitler will stop it working.

ok, it’s only some test assertions that broke as they couldn’t find baseUrl or Username properties I was using to make sure it was returning the delegated client correctly.

Version is there though so I just used that. problem solved.

1 Like