1

In Marklogic, do we have any preference over service call among REST API and XCC?

Which is better for performance and why? Or which one is suitable in what scenario ?

Assumption - Java layer is always present in the system.

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
anuj_gupta
  • 131
  • 4

1 Answers1

1

In terms of performance, XCC will likely outperform REST API calls. It avoids the overhead of the REST rewriter and request/response processing.

However, it's also important to note that you can make HTTP calls to a MarkLogic HTTP server without configuring it to be a REST API instance. You could invoke an installed JavaScript or XQuery module directly via HTTP.

MarkLogic Data Services provide another means of creating services and generating the Java classes that will be used to invoke data services in an RPC manner. Similar to invoking an installed module, they avoid the overhead of the REST rewriter and parameter processing and can perform better than REST API calls.

The advantage of the MarkLogic REST API is that they provide some standard out of the box functionality that can be leveraged. The MarkLogic Java Client API sits on top of the REST API.

There are pos and cons for either of them. Which to use may depend a lot on performance requirements, preferences for how much code to write vs. leveraging APIs and provided functionality.

Also, note that things don't need to be exclusive. Use what makes sense when it makes sense, and mix-n-match if you need. For instance, maybe most calls work fine and would leverage the Java Client API, but a few particular calls either use XCC or Data Services for high volume and velocity requirements in which every millisecond counts.

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
  • Thanks, but based on your comment it can be said, if we have option to go for XCC then that is better for performance. – anuj_gupta May 30 '22 at 08:52