1

Both JVM and V8 perform optimizations and deoptimizations on the code they produce, but optimizations usually require the VM to profile the code while it's running.

Now, If my app is running on a server, that won't be a problem since the code is always running, but if I were to use serverless, the functions would run in a sporadic manner (in an event-driven manner only when they are needed), which won't allow the VM to profile or optimize my functions.

So, Does this mean that running serverless would be inherently slower because it lacks optimizations, or does FaaS work in a different way to allow the optimization of my code?

K. Ali
  • 45
  • 2
  • 4
  • That would depend on on the specific service you intend to use and how they are implemented (e.g. whether they keep running instances alive for some time). Check their documentation. – the8472 Jun 21 '18 at 22:26
  • Optimizations happen when it runs long enough. If it doesn't run long enough, the absence of these, profile-based optimizations won't matter, as loading and initialization will dominate the execution time anyway. The JVM also has optimizations which do not depend on the availability of a profile. Further, as the8472 said, that depends on how the service has been implemented. E.g, the service implementation could freeze the JVM state and restore it instead of restarting the JVM each time. – Holger Jun 22 '18 at 12:35
  • Running serverless is inherently *much* slower for many reason of which a lack of optimisations, or optimised code, or program start up or any resources it needs. Serverless is best when a service is rarely used e.g. every few second or minutes. – Peter Lawrey Jun 25 '18 at 09:40

0 Answers0