We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Optimizing Phoenix Template Rendering through Meta-programming
188
clicks
Source: youtube.com
Andrew Selder, a senior staff engineer at Estée Lauder, discussed a significant performance bottleneck in rendering dynamic templates for multi-tenant eCommerce platforms. Initially, rendering brand-specific templates was taking 400-500ms due to them not being compiled at compile time. Phoenix is known for fast template rendering, so Selder's team aimed to match that performance. Using Elixir's meta-programming capabilities, they devised a method that leveraged `eex function from string` to twice compile templates to functions that return IO lists, which are handled efficiently by Phoenix. Benchmarks showed a 300x improvement over the previous method, dropping render times from 10 milliseconds to orders of magnitude less. This approach also included challenges like tracking changes and avoiding compilation at runtime for every consumer request, hence a gen server was used to manage template compilation efficiently. The results were a significant reduction in page load times, from an average of 600ms to around 150ms, improving the end-user experience.
Related posts
© HashMerge 2024