Handlebars-Net / Handlebars.Net

A real .NET Handlebars engine
MIT License
1.24k stars 214 forks source link

Static Handlebars instance thread safety #471

Open RohanChhipa opened 2 years ago

RohanChhipa commented 2 years ago

Hi ☺️

Regarding the static instance of handlebars, is it possible to observe blocking behaviour when that instance is accessed with multiple threads?

During our load test for our web API, we're seeing some Compiles going through while some aren't. We're actually looking into possibly creating a new instance for each request that comes through but also just wanted to have a forum around whether or not there have been multi-threading issues with the static instance.

oformaniuk commented 2 years ago

Hello @RohanChhipa I'm not aware of any such issues. I'd be happy to help you with the investigation and fixing the problem if one found.

Btw, why are you doing Compile on each request? This operation is pretty expensive. Have you thought on reusing compiled templates?

oformaniuk commented 2 years ago

Might be related to https://github.com/Handlebars-Net/Handlebars.Net/issues/498