Java企业应用-性能优化原则, 方法与策略.pptx

上传人(卖家):无敌的果实 文档编号:5271765 上传时间:2023-03-04 格式:PPTX 页数:26 大小:1.25MB
下载 相关 举报
Java企业应用-性能优化原则, 方法与策略.pptx_第1页
第1页 / 共26页
Java企业应用-性能优化原则, 方法与策略.pptx_第2页
第2页 / 共26页
Java企业应用-性能优化原则, 方法与策略.pptx_第3页
第3页 / 共26页
Java企业应用-性能优化原则, 方法与策略.pptx_第4页
第4页 / 共26页
Java企业应用-性能优化原则, 方法与策略.pptx_第5页
第5页 / 共26页
点击查看更多>>
资源描述

1、Java企业应用-性能优化原则,方法与策略Outline1.Performance Basics and Methodology2.Fundamentals of Performance Tuning Profiling Driven Optimization JVM Tuning GC JIT3.Optimization Strategy for JavaEE4.RecapRecall Littles lawL=*WIn queueing theory,the long-term average number ofcustomers in a stable system,L,is equal

2、 to the long-termaverage arrival rate,multiplied by the average time acustomer spends in the system,Wsource:https:/en.wikipedia.org/wiki/Little%27s_lawThroughput and RTMeanNumberInSystem=MeanThroughput*MeanResponseTime.Throughput and RT are related Decreasing RT”almost always”improves Throughput Thr

3、oughput improving doesnt necessarily mean RTdecreasing.Performance tuning and cost saving More higher throughput/lower RT but without addingnew hardwaresource:https:/en.wikipedia.org/wiki/Little%27s_lawApproaches to PerformanceApp Algorithm optimization Profiling-drivenAppServerJava VM Upgrade(JDK&O

4、S)JVM(OS)Tuning SpecializationOperating SystemHardware Use new hardware Use cheaper hardwareJavas viewApproaches:a)Outside in approach(performance baseline)b)Layered approach(“Bottom up”or“Top down”)c)A hybrid of both a),b)Amdahls Scaling Law1Speedup=1+F:is fraction of workthat is serialN:is number

5、ofthreadssource:https:/en.wikipedia.org/wiki/Amdahl%27s_law Reduce the amount of serial work performedCosts Reduce Scaling1.Potential contributors to F:.Synchronization(synchronized&j.u.c.Lock)data structures need to be thread.JConsole(MXBean).Java Mission Control.JProfilersafe communication overhea

6、d between.HealthCenter&jucProfilerthreads.Infamous“stop the world”(aka STW)inJVM2.Cost incurred when the N gets increased.Thread context switchProfiling:Sampling vs Instrumentsamplingmethod callbarfoobarfoomainmainInstrumentbarfoomainAvailable Technology:BCI,JVMTi,javax.management,System.currentTime

7、Millis()Sampling vs Instrument.Sampling Lower overhead(determined by sampling interval)Discover unknown code Non intrusive No execution path Periodicity Bias.Instrument Wall time(estimate IO time)Full execution path Configuration on what methods to instrument Generally more data to be collectedSafep

8、oint Bias.Stack trace sampling happens only when thegiven thread at a safepoint The hot loop may not get profiled anymore.Use following tools instead Java Mission Control Honest Profiler(githup)ZProfiler(alipay internal profiling tool)Tools for Diagnostics Most of them could be found in JAVA_HOEM/bi

9、n Good reference:Troubleshooting Guide for JavaSE 6 withHotSpotVMBasics of JVM TuningGuild for GC Tuning Select the right GC algorithm parallel old,CMS and G1 collector Rule of thumb:GC overhead is ideally 10%Choose the right heap sizesource:Charlie Hunt,Binu John JavaTM performance Configure the ap

10、propriate GG parametersJIT and common optimization Important concepts Profiler guided optimization(PGO)Optimization decisions are made dynamically Mix mode execution Some common optimization Inlining Intrinsic Monomorphic dispatch Liskov substitution principleSubtypes MUST be substitutablefor their

11、base typesJIT Profiling with JITWatch JITWatch:a graphical visualization and analysis tool forunderstanding the JITEnabled by:-XX:+UnlockDiagnosticVMOptions-XX:+TraceClassLoading-XX:+LogCompilation-XX:+PrintAssemblyTypical distributed JEE architectureJava EE ContainerJava EE ApplicationRemote Bean v

12、ia RMIREST Service via HTTPDB via JDBCSystem AcloudSystem BcloudSystem CcloudThe problem.Add communication cost RPC serialization/deserialization.Can not shift resources towardsdemand.Can not share the underlying Javaartifacts(such as JIT)Multitenancy for JavaEEAppApp1 App2 App3 AppxAppServerAppServ

13、erJava VMJava VMOperating SystemHardwareOperating SystemHardware Run multiple Java EE applications(as tenants)into same Java EE containerHigh Density Cloud for JavaEEThe JavaEE applications developedseparately can be deployedseamlessly into the same container.devOps Orchestrate JavaEE application at

14、scale Infrastructure Multi-tenant JavaEE container Virtualized JVMsource:https:/Tomcat/JDK extended for PaaS AliTomcat:run multiple apps side-by-sideApp1App3 AppxApp2safelyAliTomcat(Multi-tenant)AJDK(Virtualized)OS AJDK allows for collocation of multiple JEEapps(as tenant)in a single instance of JVM

15、:Isolate application from one another.Share metadata aggressively andtransparently,such as:Hardware bytecodes of methods GC JIT:Alibaba/Alipay JDK,based on OpenJDKAAE:Alibaba Application Engine Scaling tenant application with AAE spread application evenly across hosts but pack applications on the si

16、ngle JVM as mush as possible,based on its resource capacity:CPU usage Memory(monitoring GC)DC-1DC-2AAEgFaedacbaABABBenefitsCPU100%(100*30%+100*70%)/200=50%50%ABA+BBenefits(Cont.)Eliminate the unnecessary RPC Minimize the cost caused by object serialization/de-serialization Share underlying Java artifacts as much as possible GC JIT HeapCompared with DockerDDCCPUCPUBAABCMemMemOSOSHardwareHardwareCPU overcommit via dockershared memory viaMultitenancySummary What we covered:Performance basics&methodology Performance tuning Profiling Tuning from JVM perspective Multitenancy for JavaEE

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 办公、行业 > 常用办公文档
版权提示 | 免责声明

1,本文(Java企业应用-性能优化原则, 方法与策略.pptx)为本站会员(无敌的果实)主动上传,163文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。
2,用户下载本文档,所消耗的文币(积分)将全额增加到上传者的账号。
3, 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(发送邮件至3464097650@qq.com或直接QQ联系客服),我们立即给予删除!


侵权处理QQ:3464097650--上传资料QQ:3464097650

【声明】本站为“文档C2C交易模式”,即用户上传的文档直接卖给(下载)用户,本站只是网络空间服务平台,本站所有原创文档下载所得归上传人所有,如您发现上传作品侵犯了您的版权,请立刻联系我们并提供证据,我们将在3个工作日内予以改正。


163文库-Www.163Wenku.Com |网站地图|