[ASP.NET Core 6] Performance when registering a lot of singleton as services

Hi, Does having a lot of classes registered as singleton (_builder.Services.AddSingleton(...)) reduce web app performances? In my .NET 6 web application I have like 4 macro-features that the user may or may not want to buy (e.g. ProductionAssistant, ForecastedMaintenance etc). Inside every macro-feature I have like 20 entities, e.g ProductionOrder, Product, Customer etc. As of now I'm using a single controller and a single singleton service for each macro-features. The controller receives a request and forwards it to the Singleton Service that will invoke one or more scoped services which are in charge of performing the actual query. However, as I write down the code, I notice that controllers and singleton services classes become more and more long, making reading and modifying them a bit of a pain. Should I instead make a service and a controller for each entity? would having like 80 singleton services and 80 controllers slow down the web application? Thanks
5 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
alkasel#159
alkasel#1592y ago
ok I just thought that having a lot of services registered would be "heavy"... or somethink like that eheh actually I realized it was not the correct way, I was just afraid of consequences of increasing the number of singleton services
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
alkasel#159
alkasel#1592y ago
Ok, thank you very much for the clarification
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View