Server-Side Optimization with the new Target Java SDK

Anshul Chauhan
Nov 1 · 4 min read

We are excited to announce the release of our entirely new Adobe Target Java SDK. Java, being one of the most utilized server-side programming languages, is highly leveraged by our customers. We want our customers to focus more on their business logic rather than the technicalities of integrating with our APIs. Below, we provide our server-side integration goals and best practices to optimize the performance of your Java applications when integrating with our Target Java SDK.

What’s Target Java SDK?

The Adobe Target Java SDK helps you execute a server-side integration on JVM based architectures using the Target Delivery API. It helps you retrieve and deliver personalized experiences in a highly performant manner. Furthermore, the Java SDK helps manage integrations with Adobe Experience Cloud solutions like the Experience Cloud Visitor ID and Adobe Analytics.

There are certain goals that should always be kept in mind while integrating Target on server-side. Let’s see what these are and how Target Java SDK can help you achieve them.

A sample e-commerce app integrating Target as a service using the Target Java SDK

Achieving server-side goals using Target Java SDK

Goal 1: Improve performance by reducing network chattiness

Discrete requests for a user should be collapsed into a single request using batching on server-side. The benefit is that the device then pays the price of network latency once and leverages the low latency and more powerful hardware on server-side. Using Target Java SDK you can combine mbox and views request for both pre-fetch and execute in a single request. For example:

Full sample:

Goal 2: Improve performance by embracing server-side parallelism

This should be achieved without each engineer needing to become an expert in low-level threading, synchronization, thread safety, concurrent data structures, non-blocking IO and other such concerns. Target Java SDK handles all the complexities of multithreading for you, you just need to configure it as per your needs.

Full sample:

Goal 3: Improve page load time

Make sure the client (eg. at.js) doesn’t have to make any calls to Target before rendering the content. This way the client does not block or pre-hide any section of the page resulting in faster page loads and preventing intermittent flickering. For example, if the client is browser with at.js, you just need to set the target response in a variable called serverState and at.js will render the response without making any calls to the Target server.

Full sample:

Goal 4: Maintain sessions whenever possible

The biggest challenge while integrating Target on server-side is maintaining sessions. Target Java SDK makes it easy by returning cookies along with target response. These are not actual cookies but some key/value pairs that Target needs to maintain sessions and communicate to Target edge cluster. Always make sure that these cookies are provided in subsequent calls for the same user. Target will keep refreshing the cookies, so make sure cookie values are updated in every call. These can be saved on client-side or server-side. For example, if client is browser these can be saved in client cookies:

Full sample:

Goal 5: Minimise Target latency impact

Since Target calls are independent in most cases, server integrations should make asynchronous calls to Target before preparing the content for the page to be returned. For example, DB or other network calls should be made after Target request (made asynchronously). By the time your other requests complete, Target response should also be available and total latency will be a max of(I/O calls, Target). This could be easily achieved by using Target Java SDK since it supports asynchronous calls. For example:

Full sample:

Best practices for Target Java SDK

  1. Use single TargetClient object per application lifetime: TargetClient is optimized to be used as a single instance per application lifetime. For example, TargetClient can be created as a spring bean. If your application does not support dependency injection, consider creating a static provider or singleton class to provide TargetClient instance in the application.

Java SDK is open sourced

Now, I know you are excited about our new Java SDK and its capabilities. But what’s more exciting is that you can contribute to the Java SDK since it is open sourced! But, before contributing to the Java SDK, we highly encourage you to familiarize yourself with the documentation and code. We also provided sample apps and demos that you can explore, which will in turn help expedite the familiarization process. If you feel comfortable with the code and you already see opportunities for improvement, follow our contribution guidelines outlined in the file. Next, submit a pull request through GitHub. Congratulations! You now have the bragging rights to being an open-source contributor!

Adobe Tech Blog

News, updates, and thoughts related to Adobe, developers, and technology.

Anshul Chauhan

Written by

Computer Scientist, Adobe

Adobe Tech Blog

News, updates, and thoughts related to Adobe, developers, and technology.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade