We are using HATEOAS to great effect however we have been looking at performance and getting very poor results from the building of the links, namely code which looks like this
resource.add(linkTo(methodOn(SomeController.class).findAll())).withSelfRel());
Results (I am not as concerned about the size but recorded below anyway)
Enabled links - ~438ms - 201 kb
Disable links - ~193ms - 84.6 kb
The size is due to us putting out 8 links per resource so we expected the size, but not the speed slow down.
Approximately 232ms is spent on constructing links roughly 2ms per object I return (100 objects in this particular test)
Is there anyway to speed this up? Can we get the URI upfront for all request in the toResources
call for example and then flavor it in the toResource
?
ResourceAssembler
you decide how to get the URLs, so you can get them upfront or cache them (or part of them). – Iseabal