0

I created a new Asp.Net MVC web project. I took the decision to create two different apps, the first one would be a web REST API that would provide all data for the second one, which would essentially be a MVC web application without any database interactions. It seems to me like a great way to separate business logic to prensetation plus it would be really easy to eventualy create a mobile app that would essentially make the same call to web API for accessing data.

Here's my concern, every time I hit a page on my web app, a first http request is done to my server. Then my server makes a second http call to the REST API to get my data model before returning a response of the initial call. I really don't like the lack of responsiveness that it creates on my web app, the half second wait generated by those doubled call bothers me.

Although I really think that conceptually the idea is good, I have some doubts on the efficiency of it.

  • 2
    Probably my comments here apply as well. – πάντα ῥεῖ Apr 11 '18 at 18:52
  • What's the specific question? – Laiv Dec 25 '18 at 11:30
1

If you have a REST API, you don't need an MVC application. Instead, create a frontend JavaScript application which uses your API directly.

Compare your current scheme:

[JS/HTML frontend] <---> [MVC app] <---> [REST API]

to:

[JS/HTML frontend] <---> [REST API]

("JS/HTML frontend" is whatever user sees in their browser, be it a thin HTML page generated by your MVC application or something like React/Angular/whatever application.)

You'll have a shorter network chain, thus shorter initial loading time.

0

Are you getting a lag on just the first call to the API? Or on all calls. We've seen issues with first calls being slow due to hosting configurations set to recycle/unload disused application pools. The first request comes in which then triggers the application pool being loaded back into memory which can take anything up to 15 seconds.

It this is your issue then solutions to this involve carefully reviewing your hosting configurations, especially around recycle timings/schedules.

If you need to you can then look into whether an initial "hello" call as your MVC app starting page loads might be needed to handle a first call after a long period of user absence.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.