我在前端路由和后端路由之间有点困惑。我正在使用Angular JS和Laravel作为我的一个项目。
我想得到一个建议或者我可以在路由时减少负载平衡的方法。
因此,这将是使用路由的最佳方式。
前端路由或后端路由。
我知道这不是建议,但我搜索了很多但得不到令人满意的答案。这就是我发布这个问题的原因。
Route::post('users/{email_id}/{name}/{image_url} ', 'Userscontroller@index');
我应该将其用于路由还是
此代码位于 app.module.ts 文件
中import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { WelcomeComponent } from './home/welcome.component';
/* Feature Modules */
import { ProductModule } from './products/product.module';
@NgModule({
imports: [
BrowserModule,
HttpModule,
RouterModule.forRoot([
{ path: 'welcome', component: WelcomeComponent },
{ path: '', redirectTo: 'welcome', pathMatch: 'full' },
{ path: '**', redirectTo: 'welcome', pathMatch: 'full' }
]),
ProductModule
],
declarations: [
AppComponent,
WelcomeComponent
],
bootstrap: [ AppComponent ]
})
export class AppModule { }
我应该使用上面的吗?
任何帮助都会很棒。
谢谢。
答案 0 :(得分:0)
You will not find a concrete answer. I don't know which one is better. It depends upon what you are trying to do. It is better to measure and find out yourself. In my opinion routing alone will not have a huge impact on load balancing. Consider using Memcache, Redis etc and CDNs.
Basically speaking routing on the front end will have fewer number of HTTP requests and better for your server. You need to consider reducing the file size which reduces the number of TCP/IP extra round trips.
Also implementing some sort of non blocking asynchronous Process Pooling / Thread Pooling architecture and clamping the number of background worker on your back end will help to load balance.