Articles /

Azure Static Web Apps - Performance

While doing some performance profiling of an app made for Azure SWA we noticed a rather large discrepency between the client times we were seeing and what our server side logging was outputting.

a diagram of a software application
March 29, 2024

Diving into this deeper we made a bare bones reproduction of the issue, using an Azure Function that just returned a string and hosted two copies, one in Australia East the other in HongKong.

Azure Function Direct (AUE) - ~60ms
Azure Function Direct (HK) - ~160ms
Azure SWA (AUE) - ~300ms
Azure SWA (HK) - ~180ms

The result was pretty clear - in terms of performance (for our current location) we were going to be best off hosting the functions in HK.

It was about this point when we remembered the Enterprise Edge feature of SWA and decided to try it out - while there was quite the battle enabling it (that's another story) a really curious thing happened. Static content went way faster (dropping from 150ms to less than 50ms) which wasn't surprising as there was a node in our country, however API traffic jumped up to the 800ms mark. We never quite got to the bottom of this change, but suspect enabling enterprise edge changed which data center traffic was directed to for the SWA proxy (potentially USA) thus meaning instead of jumping NZ (Location) -> HK (SWA) -> AUE (Func) whereas now it was doing something like NZ (Location) -> NZ (Edge) -> USA (SWA) -> AUE (Func).

We could probably fix a lot of that by hosting the functions in america, but suspect (admittedly didn't try) that the result would still be higher than the 180ms mark.

In the end we took a slightly different approach, ditching the SWA proxy feature and went directly to Azure Functions directly from javascript, meaning we had to deal with CORS and Auth but the resulting overhead for each api call was only 60ms instead of the original 300 (or 180 if hosted in HK). Pity as it means we lose some of the advantage of SWA, but gave the best result and would be fairly easy to rever later if Microsoft ever release something that fixes the issue.

Since then Microsoft have released a new feature for distributed functions  and announced (in LinkedIn comments at the least) that they're looking into making the SWA service more global, potentially increasing the number of regions its in next year.

Until then we'll likely continue on with the little bypass hack, at least for clients located within Australasia. Especially once the NZ North data centre is live this little hack will have even more impact.

a group of people sitting at a table with laptops

Elevating Excellence: Our Microsoft Partnership!

Our ongoing collaboration with Microsoft brings you the best in innovation and technology.

Tell us about your project

Got a question, need support, or ready to explore possibilities? We're here to help. Fill out the form and our team will reach out within 1-2 business days.