We are building a REST API which creates items in a CDN. Each item takes between 5 and 7 seconds to create, and we need to create them as quickly as possible until we have about a million of them.
One school of thought in our office is that we should make lots of small transactions. Another is that we should have fewer, larger transactions to minimise network "chat", perhaps running as described here.
Small transactions would be simpler to implement. They would involve a bit more network traffic (perhaps insignificant given the time per item). They could also be advantageous in the event of a failure to create an item.
Performance is our top priority, development cost a close second. This post suggests that either is OK in principle. Which/how do I choose?
Our CDN will serve up images of properties in New Zealand. We will pre-populate the CDN with six images of each property we think is likely to be requested. The different images are used by various pages in our website.
The image generation process looks like this:
for each property {
call remote 3rd-party API to find property details;
for each type of image required {
call remote 3rd-party API to get image;
}
}
The remote API calls each take between 1 and 2 seconds. The remote API is on the opposite side of the planet to our users and our servers. The stuff that happens locally is in the millisecond range. I'm using C# async
where possible.
If somebody requests an image that isn't already cached in the CDN, it generally comes back in two or three seconds, which is acceptable. We load it with AJAX too, so the user isn't kept waiting.