cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

ThingWorx Navigate is now Windchill Navigate Learn More

Translate the entire conversation x

Best Practice for Providing Large Image Sets (25 Images per Folder, ~400 KB Each) via API

MA8731174
16-Pearl

Best Practice for Providing Large Image Sets (25 Images per Folder, ~400 KB Each) via API

Hi everyone,

I am currently working on a use case where we have multiple repositories, and each path contains around 25 images, each with a file size of approximately 400 KB.
The customer would like to retrieve (“auslesen”) these images via an API from ThingWorx.

Before I implement the solution, I would like to get some best-practice recommendations from the community:

My Questions

  1. What is the best way to prepare and serve many images via API in ThingWorx?
    Should we use:

    • LoadBinary for each image,

    • LoadImage,

    • SaveImage / Base64 output,

    • or another recommended approach?

  2. Is it more efficient and possible to:

    • Return image streams directly,

    • Convert them to Base64,

    • Or provide download URLs (e.g., via Content Caching)?

  3. Are there performance concerns when retrieving 25×400 KB = ~10 MB per request from a ThingWorx server?
    Any recommended throttling, batching, or pagination strategies?

Goal

We want to provide the customer with a clean, fast, and scalable API that allows them to retrieve all images from a given folder path.


Looking for advice on optimal services, data structures, and performance considerations.

 

Thanks in advance for any suggestions or insights!

ACCEPTED SOLUTION

Accepted Solutions
slangley
23-Emerald III
(To:MA8731174)

Hi @MA8731174 

 

To effectively prepare and serve multiple images via an API in ThingWorx, consider the following best practices:

 

Image Retrieval Methods:

  • LoadBinary: This method can be used for retrieving binary data, but it may not be the most efficient for multiple images.
  • LoadImage: This is specifically designed for image retrieval and may be more suitable for your use case.
  • SaveImage / Base64 Output: While converting images to Base64 can be useful, it increases the size of the data being transmitted, which may not be ideal for performance.
  • Direct Image Streams: Returning image streams directly can be efficient, especially if the client can handle the binary data.

Performance Considerations:

  • Retrieving 25 images at approximately 400 KB each (totaling around 10 MB) in a single request can lead to performance issues, especially if multiple users are accessing the API simultaneously.
  • Consider implementing throttling to limit the number of requests per user or per time period.
  • Batching or pagination strategies can help manage the load. For example, you could retrieve images in smaller groups (e.g., 5 images per request) to reduce the data load and improve response times.

Content Delivery:

  • Providing download URLs via content caching can be an effective way to serve images. This allows clients to download images directly, reducing the load on the ThingWorx server.
  • Ensure that caching is properly configured to enhance performance and reduce repeated data retrieval.

 

Hope this information is helpful.

 

Regards.

 

--Sharon

View solution in original post

1 REPLY 1
slangley
23-Emerald III
(To:MA8731174)

Hi @MA8731174 

 

To effectively prepare and serve multiple images via an API in ThingWorx, consider the following best practices:

 

Image Retrieval Methods:

  • LoadBinary: This method can be used for retrieving binary data, but it may not be the most efficient for multiple images.
  • LoadImage: This is specifically designed for image retrieval and may be more suitable for your use case.
  • SaveImage / Base64 Output: While converting images to Base64 can be useful, it increases the size of the data being transmitted, which may not be ideal for performance.
  • Direct Image Streams: Returning image streams directly can be efficient, especially if the client can handle the binary data.

Performance Considerations:

  • Retrieving 25 images at approximately 400 KB each (totaling around 10 MB) in a single request can lead to performance issues, especially if multiple users are accessing the API simultaneously.
  • Consider implementing throttling to limit the number of requests per user or per time period.
  • Batching or pagination strategies can help manage the load. For example, you could retrieve images in smaller groups (e.g., 5 images per request) to reduce the data load and improve response times.

Content Delivery:

  • Providing download URLs via content caching can be an effective way to serve images. This allows clients to download images directly, reducing the load on the ThingWorx server.
  • Ensure that caching is properly configured to enhance performance and reduce repeated data retrieval.

 

Hope this information is helpful.

 

Regards.

 

--Sharon

Announcements


Top Tags