When and why prefer container.component over router.component?

What is the point of container.component workers over using router.components other than container.components will run under a separate process (or processes) than the router worker?

What I researched before asking:
Docs explain container.components run python apps natively unlike guest components, yet router.components presumably also run python apps natively, so seems like no speed advantage.

Container.components each need boilerplate auth calls to register whereas router.components auth is implicitly handled. That seems more like a kluge/workaround to make container.components work, not a benefit of container.components.

After scouring docs and other github posts, I also read forum questions from 2014 and 2016 (Components in Containers vs. Components in Routers?).

Router components run in the same process as the router; they must be written using Twisted Python and if they crash the process that router is also crashed. The best general answer is to use container-components, because these isolate “application” code from core router functionality.

You also have to take care to not cause reactor slowdowns – if any of your application code running as an in-router component takes “too long” to complete before letting the reactor do something, this can affect all other connections to that router. (There is one router per process).

Very small / fast and simple things (e.g. authentication) might be a good choice for an in-router component. Anything complex should be in a separate process (i.e. container or guest)

Thanks meejah. I’m the same person who’s writing up the docs PR example on containers that you thought might be helpful to others (about a month or so ago) so I wanted to make sure I really understood what was going on with my final review of the new example. First time on the forum…looks like I don’t mark this topic as “closed” like github issues??, but rather I check the solution box? Happy New Year!

Yes, that’s how its meant to be i.e when a comment is the “answer” to your original question, it makes sense to mark that as solved, so that anyone else stumbling across a similar question/issue could easily see the solution.