question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create router once

See original GitHub issue

Hi! Continuing #73 discussion.

Now for each http request on server side we have to create router instance with routes tree and options, attach plugins and middleware. And then run route.start. We do it for creating different context for each request. But why should we apply the same routes tree, options and plugins again and again, parsing all that stuff just for creating context?

I think it doesn’t make any sense. Router should be created once with routes tree and options, plugins and middlewares, whilst route.start should spawn new context on each request on server side and once on client side (I still don’t see any real cases of router.stop). Plugins and middlewares should depend on this context. For now I don’t see benefits from https://github.com/router5/router5/issues/73#issuecomment-244713011, anyway I can create middleware on each router creation and bind it in closure by myself.

I mean, mechanism that we have in 4.0 is expensive on server side and not really useful. It can be improved!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
davidecantonicommented, Jan 15, 2018

Hi everybody and @troch, I just wanna share some data related to this topic and was wondering if cloning is the best current available solution? Registering about 220 routes dynamically on each express route call will take around ~300ms which is a big pain and slows down the app massively! By registering the routes on bootstrap and only cloning the routes on each express route call will reduce the overhead to around ~10ms. Thanks for your feedback!

0reactions
trochcommented, Jan 27, 2018

Hey @davidecantoni, thanks for sharing. That’s great to hear!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Connect One Router to Another to Expand a Network
Connect the modem to the first router. Use an Ethernet cable to connect to the WAN port of a router to the WAN/Internet...
Read more >
How to Set Up a Router - Step-by-Step - Cisco
Step 1: Decide where to place the router · Step 2: Connect to the Internet · Step 3: Configure the wireless router gateway...
Read more >
Router - Make
The Router module allows you to branch your flow into several routes and process the data within each route differently. Once a Router...
Read more >
How To Connect 2 Routers On 1 Home Network - YouTube
Using 2 routers, turning one router into a WiFi Extender is going to degrade your WiFi. Yes it's a feature and you may...
Read more >
Router Help Docs | Integromat Help Center - Make
The Router module allows you to branch your flow into several routes and process the data within each route differently. Once a Router...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found