ASP.NET MVC Web - How to separate the performance between the modules of a project?

2

Explaining the doubt. Within my system there are some menus, let's use as example 3, naming them A, B and C, each being a CRUD module with some kind of report. If 300 people are using module A, it will impact the performance of module B, right? 300 people ordering something from the bank at the same time, etc. Not to mention that it also influences the performance of the server when the system is published (IIS), until it is correct? Correct me if I'm mistaken, please. This counts for any other module. How do I make a particular module not influence the performance of other modules? That's what the client is asking to do in a single module. Will API work? I do not know the usability of the API. If anyone here knows and tells me that this would separate this performance "problem", I will look for more information to be able to develop. Or Web-Service? Anyway, right away my project manager 'suggested' to do another mvc project myself, also separating the banks, and calling by iframe. Would it be the best solution? I'm not sure if this is the case, but I do not know how to do that, and I still do not know what the validation part of the login would look like, since it would come from the 'original' system, not the iframe project.     

asked by anonymous 29.05.2017 / 01:29

3 answers

5

As the Cigano has already listed very well the points of your question and responded to the height, I will only suggest some links and make some suggestions of technologies to be used.

Since you are using ASP.NET MVC , make sure that all your Action s are marked with async Task<> return.

So where do you find it:.

public class MyController : Controller
{
    public ActionResult MyAction(int id)
    {
        var model = db.Colecao.Find(id);
        return View(model);
    }
}

change to.:

public class MyController : Controller
{
    public async Task<ActionResult> MyAction(int id)
    {
        var model = await db.Colecao.FindAsync(id);
        return View(model);
    }
}

The same goes for WebAPI, so find yourself.:

public class MyController : ApiController
{
    public Entidade MyAction(int id)
    {
        var model = db.Colecao.Find(id); 
        return model;
    }
}

change to.:

public class MyController : ApiController
{
    public async Task<Entidade> MyAction(int id)
    {
        var model = await db.Colecao.FindAsync(id);
        return model;
    }
}

With this, you make your Asynchronous Actions, with this simple change your system can support thousands of requests per minute, as you can see in the following Artigo/Benchmarking - Node.js vs. IIS + WebAPI async – Performance Test

Now regarding Banco de Dados , you can and should use Entity Framework to speed up its development, just remember to use asynchronous methods whenever they are available: such as FindAsync , ToListAsync , ToDictionaryAsync , FirstOrDefaultAsync , AnyAsync , MeuMetodoAsync .

But remember, Entity Framework is just a tool, nothing prevents you from using another in conjunction with it, such as Dapper , I recommend that you use Dapper whenever you have a more critical query for the system, either because it is very requested or if you need to write your own SQL , in any case, do not forget to use Async methods, like QueryAsync . Here is a link to justify this tip: Dapper vs Entity Framework vs ADO.NET Performance Benchmarking

As for your front-end , as I do not know your team's knowledge of JavaScript, I would advise you to set aside jQuery and use VueJS , even if you decide to% / p>

Template

public class Entidade
{
    public Int32 EntidadeID { get; set; }
    public String Descricao { get; set; }
}

Controller

public class MyController : Controller
{
    public async Task<ActionResult> MyAction(int id)
    {
        var model = await db.Colecao.FindAsync(id);
        return View(model);
    }
}

Controller

@model Entidade
<div id="conteudo">
    <input type="hidden" id="EntidadeID" name="EntidadeID" v-model="EntidadeID">
    <label>
        Descrição: 
        <input type="text" id="Descricao" name="Descricao" v-model="Descricao">
    </label>
</div>
@section scripts {
    <script type="text/javascript">
        var model = @(Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model)));
        new Vue({
            el: '#conteudo',
            data: model
        });
    </script>
}

At first glance it looks like a bad trade-off (% w / w% w / w% w / w), but remember, you're transferring responsibility for rendering the page to Multiple Page Application , and it will be much simpler to refresh the page after requests Razor (due to Vue created by Cliente ).

To learn more, visit the links: AJAX , bind bi-direcional and VueJS .

Remembering that VueJS can be incremental, you do not need to rewrite your entire application before you can start using it.

Of course, you can make a Vue JS Brasil application, using Vue.js is easier to learn than jQuery and VueJS of your preference, such as SPA , Async WebAPI or Framework JavaScript itself, follow a link of tutorial Angular

    
29.05.2017 / 14:56
2
  

If 300 people are using module A, it will impact the performance of module B, right?

Yes, because it is a single system, but 300 people usually do not even tickle the service if you use the correct practices for databases, asynchronism, and good cache strategies.

  

300 people ordering something from the bank at the same time, etc. Not to mention that it also influences the performance of the server when the system is published (IIS), until it is correct?

Yes, but, as I said, it's too early to think about solving performance. First you need to measure how the server behaves before proposing something to solve, in the sense of modularization, which is what your question sets out to elucidate.

  

How do I make a particular module not influence the performance of other modules?

As I said, using the correct practices for databases, asynchronism, and good cache strategies.

  

Will API work? I do not know the usability of the API. If anyone here knows and tells me that this would separate this performance "problem", I will look for more information to be able to develop. Or Web-Service?

(Web) API and Web Service are almost the same thing. The difference is that one implements REST and another implements SOAP. Regardless of implementation, this has little or no influence on the performance issue as a whole.

  

Finally, my project manager 'suggested' to do another mvc project, separating the banks, and calling the iframe. Would it be the best solution?

Not at all. The server work is the same and you still have a bad practice of using <iframe> where you do not need it.

  

I'm not sure how much of a project to validate the login, since it would come from the 'original' system, not the project that is inside the iframe.

And indeed, it is.

If you need advice on this, see my profile on my profile. I can consult more about your problem.

    
29.05.2017 / 07:55
1

I endorse the answers of the Gypsy, but in the question below, I am of another opinion. But it does not mean that it is my answer or that it is right or wrong, or worse or better.

  

Finally, my project manager 'suggested' to do another mvc project, separating the banks, and calling the iframe. Would it be the best solution?

Look for never to use IFRAME , really is a bad practice - even gambiarra. But to separate the modules, each one in a project, this yes is possible to talk. I have seen many projects where there is no need to have a monolithic project, and the system begins to become complex just because it tries to keep everything in one environment. And if it's segmented, everything gets clearer and lighter.

It's not complicated to begin to understand if this separation is interesting. A very superficial pre-analysis, which begins with asking: What is the flow of data? If the answer is something like this:

  • The entity / data is started and prepared in Module A;
  • Module B only deals with information that Module A allows;
  • Module C only deals with information that Module B allows;
  • So it's easy to see that the modules are fully decoupled. They can easily be different projects, independent database, and everything else.

    A legal example is a store, where you can have 3 totally independent systems:

  • LOGISTICA (PHP + MySQL) : Shopping and receiving new products. After the product is ready to be sold, it is sent to the STORE.
  • SHOP (SAP + NodeJS + MongoDB) : Receives the product, publishes it in the store, adds it to the shopping cart and sells it.
  • ACCOUNTING (ASP.NET + SQLServer) : Get the purchase order, valid and effective sale, send message to the logistics to make delivery.
  • One solution, but several projects, with several technologies. Logistica does not need to know that there are customers users, nor processes of purchases. The Store does not need to know that there are truck delivery procedures, how products are organized in stock, etc. And Accounting just needs to know about purchase orders, and money, nothing needs to know about customers or trucks.

    Finally, separating your solution by scope of responsibilities is healthy, yes, as long as necessary and know how to do it.

        
    29.05.2017 / 14:35