简体   繁体   English

如何优化Google App Engine应用程序的Spring Framework使用

[英]How can I Optimize Spring Framework usage for Google App Engine Applications

Google App Engine frontend instances are dynamically scaled. Google App Engine前端实例是动态扩展的。 That means App Engine automatically creates new instances when load increases and turns off instances when they are not being used. 这意味着App Engine会在负载增加时自动创建新实例,并在不使用实例时关闭实例。 Reloading instances may result in additional latency for users. 重新加载实例可能会导致用户的额外延迟。 Frontend instances also have a 60 seconds deadline to complete a given request. 前端实例也有60 seconds截止日期来完成给定的请求。

As I am using Spring MVC and Spring IOC in my GAE application, to Optimize Spring Framework usage, I have gone through Best Practices for App Engine Applications . 当我在GAE应用程序中使用Spring MVC and Spring IOC时,为了优化Spring Framework的使用,我已经完成了App Engine应用程序的最佳实践

In that link I am completely confused with the section Reducing or Avoiding the Use of Relationship Autowiring . 在该链接中,我完全混淆了减少或避免使用关系自动装配的部分 It says automatic wiring can significantly the time required to resolve the beans during application initialization time, so they suggest autowire byName instead of using autowire byType . 它说, automatic wiring可以解决在应用程序初始化时间豆显著所需的时间,所以他们建议自动装配byName而不是使用自动装配byType

So my question is How autowire byName reduces bean resolving time ?? 所以我的问题是autowire byName如何减少bean的解析时间? . And also I would like to know is there any better way to inject beans ?. 而且我想知道有更好的注入豆子的方法吗? Is there any best practices for Spring IOC to reduce application initialization time. 是否有任何Spring IOC最佳实践可以减少应用程序初始化时间。

Autowire "byType" obviously have to use some mechanism (and some processing )to correctly identify the bean whereas using "byName" provide a direct identification. Autowire“byType”显然必须使用某种机制(和一些处理)来正确识别bean,而使用“byName”提供直接识别。

Take an analogy of a group of many breed of cats and dogs. 比喻一组多种猫和狗。 To find the terrier out of the group you will have to first identify all breeds however when you use name of dogs it is much easier and improve the identification. 要找到群体中的小猎犬,您必须首先识别所有品种,但是当您使用狗的名称时,它更容易并且改进识别。

Spring does scanning of the classes for annotations which are inside package defined in "context:component-scan" if there are many classes in package it will take a while during start-up of an application hence it is suggested to use autowire byName. Spring会扫描类中的注释,这些注释位于“context:component-scan”中定义的包内,如果包中有许多类,则在启动应用程序时需要一段时间,因此建议使用autowire byName。

Let me give a reply to all the answers 让我回答所有答案

So my question is How autowire byName reduces bean resolving time ?? 所以我的问题是autowire byName如何减少bean的解析时间?

already explained by apurvc, in particular if you use interface or you use massive class inheritance Spring will have to inspect the hierarchy of classes 已经由apurvc解释过,特别是如果你使用接口或者你使用大量的类继承Spring必须检查类的层次结构

I would like to know is there any better way to inject beans ? 我想知道有更好的注入豆子的方法吗?

  1. Yes, do not inject bean by autowire but use set or get property , as you can; 是的,不要通过autowire注入bean,而是使用set或get属性 ,因为你可以; I use this policy. 我使用这个政策。
  2. Avoid autoscan component 避免使用自动扫描组件
  3. Use singleton or bean pools or factory to reuse or construct object 使用单例或bean池或工厂来重用或构造对象

Is there any best practices for Spring IOC to reduce application initialization time. 是否有任何Spring IOC的最佳实践可以减少应用程序初始化时间。

  1. use lazy initialization ( @Lazy annotation) 使用延迟初始化( @Lazy注释)
  2. put not dependent bean at the top of XML definition 将非依赖bean 放在 XML定义的顶部

But you do not really need these solutions if you are JEE developer. 但如果您是JEE开发人员,那么您真的不需要这些解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Google App Engine上使用Spring Framework创建表单登录名 - How to create a form login with Spring Framework on Google App Engine 如何在适用于Google App Engine(标准)的Spring Boot应用程序上使用调试器 - How can I use the debugger on a Spring Boot application for the Google App Engine (standard) 如何初始化 firebase 托管在谷歌应用引擎上的 spring-boot 应用程序 - How can I initialize firebase a spring-boot application hosted on google app-engine Google App Engine中的内存使用情况 - Memory usage in Google App Engine 如何在Google-app-engine数据库中保存列表? - How can I save a list in google-app-engine database? 如何在JDO中(在Google App Engine上)延迟加载属性? - How can I load a property lazily in JDO (on Google App Engine)? 如何在Quercus上使用Google App Engine的memcache? - How can I use Google App Engine's memcache with Quercus? 如何减少Google App Engine数据存储延迟? - How can I reduce Google App Engine datastore latency? 如何更新Google App Engine中的实体 - How can I update entity in Google App Engine 如何在Google App Engine Java上减少Appstats的内存使用量 - How to reduce the memory usage of Appstats on Google App Engine Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM