This tutorial walks you through getting up and running on the Ampere A1 compute platform on Oracle Cloud Infrastructure (OCI). You'll start by running the Spring Boot app in JVM mode, then build and run Micronaut. in native binary formIO application. With GraalVM, you can not only improve the performance of your existing applications, but also build lightweight, multilingual applications for the cloud. For the Ampere A1 form factor, it offers linear scalability and unmatched price/performance, making it the ideal companion. Based on Ampere Altra CPUs, the Ampere A1 compute platform is revolutionizing enterprise and application developers who are building scalable workloads from edge devices to cloud data centers. The unique design of this platform provides consistent and acceptable performance because there is no contention for resources within the compute core, providing more isolation and security. This new form factor of computing on Oracle Cloud Infrastructure combines the power of the Altra CPU with the security, scalability, and service ecosystem of OCI to provide an unmatched platform. GraalVM is a high-performance runtime environment for applications written in J**A, J**Ascript, LLVM-based languages such as C and C++, and other dynamic languages. It dramatically improves the performance and efficiency of your applications, so you can run your existing applications on the cloud more efficiently. GraalVM can also build native executable binaries - native images for existing JVM-based applications. The resulting native image contains the entire program in the form of a machine**, which can be executed immediately, avoiding the startup and memory occupation of the JVM itself. This capability makes GraALVM ideal for building cloud-native applications, and several microservices frameworks in the JVM language now include this capability. In this tutorial, you will: Create an Ampere A1 compute instance.
Install GraalVM Enterprise Edition.
Use GraalVM to run the popular Spring Boot sample application PET Clinic in JVM mode
Build and run the Micronaut application with a GraalVM native image.
Evaluate the suitability of using GraALVM on Ampere A1.
Clean up the deployment. Oracle Free tier (trial), paid, or LiveLabs cloud accounts.
Familiarity with the OCI console.
Network Overview. Familiarize yourself with the compartment.
Basic conceptual knowledge of containers and podman.
You will begin initializing the Oracle Cloud environment for creating and deploying J**A EE applications. The environment will be contained within a cloud compartment, and communication within the compartment will take place over a virtual cloud network (VCN). The compartment and VCN will isolate and protect the overall environment. You will create an Ampere A1 compute instance to install and run the application using GraalVM Enterprise Edition. Open the navigation menu. Under "Governance & Management", go to "Authentication" and click on "Compartments". On this screen, you will see a list of compartments, tap on "Create Compartment".
Enter the following information:
Name: Enter "appdev".
Description: Enter a description (required), for example: "appdev compartment for getting started tutorial". Avoid entering confidential information.
Parent compartment: Select the compartment where you want the compartment to be located. Defaults to the root compartment (or tenant).
Click on "Create Compartment".
Your compartment will appear in the list.
To create an Ampere A1 compute instance, use the navigation menu in the upper-left corner of the console and go to Compute Instances.
Open the instance creation process.
Verify that you are in the appdev compartment.
Click Create Instance.
On the Create Instance page, you will create a new instance and new network resources, such as a virtual cloud network (VCN) and an Internet gateway (IG).
Name the instance GraalVMapp
Update the image selection to use Oracle Linux 79。
Click the "Change Shape" button to see the available calculated shapes.
4.Configure an image for your instance. Click the "Change Image" button to view the available operating system images.
Select Oracle Linux 79。
5.Configure resources for your instance. Select Ampere Arm base processor in the shape family selection.
Choose from a list of shapes with the Ampere Arm base processorvm.standard.a1.flex
Shape. The Ampere A1 shape is flexible, and you can modify the number of cores and the amount of memory. Select 1 core and 6 GB of memory for the VM.
6.Choose your network option. Create new VCNs and subnets for your next cloud deployment. Make sure that you choose to assign a public IP address to your instance. 7.Generate and **SSH key pairs. This step is optional but highly recommended for later maintenance and upgrades. If you already have a key pair, you can also use your public key. If you want to learn how to generate an SSH key, follow the instructions in the Generate SSH Key tutorial.
8.Click Create to create the network resource and start the compute instance.
In order for the application to be accessible from the internet, you need to open the ports that the application will use. In this section, you'll configure security lists on your cloud network and firewall rules on compute instances to enable your applications to send and receive traffic. A security list acts as a virtual firewall for your instance, with inbound and outbound rules that specify the types of traffic that are allowed to enter and exit. Security lists are configured at the subnet level, applying security rules to all network elements in that subnet. Your network comes with a default security list that contains an initial set of rules. The default security list allows you to connect to an instance using SSH and allows the instance to make outbound network calls to any destination. Navigate to the details page of the instance you created. Compute Instance: Click the instance that you created.
By clicking on the subnet, navigate to the subnet to which the instance is connected.
On the Subnets page, click the default security list to view the details and configure it.
Click "Add Inbound Rule" to add a new rule that allows incoming traffic that matches the rule.
Add an inbound rule that allows incoming traffic a. on port 8080Set the source CIDR to。This allows incoming traffic from all sources. b.Set the destination port range to 8080. This sets the destination to port 8080 only. The rule now allows traffic from all sources to use port 8080. This is exactly what we need so that our app can be accessed from anywhere. c.Provide a description.
Firewall rules control packet-level traffic to and from an instance. You need to configure firewall rules directly on the instance itself to provide you with an extra level of security. Navigate to the details page of the instance you created. Compute Instance: Click the instance that you created.
Copy the public IP address of your instance.
Use SSH to connect to the instance. Use a key that you generated yourself or that you provided during the instance creation step. The default username for instances using the Oracle Linux operating system is OPC.
Run the firewall configuration command. This modifies the firewall of the instance itself to expose port 8080 and accept incoming traffic.
OCI offers Oracle GraalVM Enterprise Edition at no cost to its customers. GraalVM Enterprise Edition support is included with Oracle Cloud Subscriptions. The combination of the high-performance ARM-based computing form factor with GraalVM Enterprise Edition on OCI provides a compelling platform for existing and new enterprise applications. Navigate to the details page of the instance you created. Compute Instance: Click the instance that you created.
Copy the public IP address of your instance.
Log in to the instance by using SSH. Use a key that you generated yourself or that you provided during the instance creation step. The default username for instances using the Oracle Linux operating system is OPC. To install GraalVM and Git on OCI, run the following command:
Once installed, GraalVM can be found in the usr lib64 GraalVM directory. GraalVM includes a JDK, and by default, it replaces the J**A top-level JIT compiler with the GraALVM compiler. The new and innovative GraALVM compiler can improve the performance of your existing JVM applications. Once GraalVM is installed, the j**a runtime is ready to use on your system, and you can check the version with the following command.
As an example of an existing J**A application, we can run the Spring Petclinic sample application, which is built with Spring Boot. Clone the repository to get started.
2.Build and run applications.
The first time you run the application, you will have dependencies. **It may take a few minutes to complete. You should see an output similar to the following example: 2021-03-05 18:11:28447 info 3704 --main] o.s.s.petclinic.petclinicapplication : no active profile set, falling back to default profiles: default2021-03-05 18:11:31.531 info 3704 --main] .s.d.r.c.repositoryconfigurationdelegate : bootstrapping spring data jpa repositories in default mode.2021-03-05 18:11:31.697 info 3704 --main] .s.d.r.c.repositoryconfigurationdelegate : finished spring data repository scanning in 144 ms. found 4 jpa repository interfaces.2021-03-05 18:11:33.436 info 3704 --main] o.s.b.w.embedded.tomcat.tomcatwebserver : tomcat initialized with port(s): 8080 (http)2021-03-05 18:11:33.720 info 3704 --main] o.a.c.c.c.[tomcat].[localhost].[/] :initializing spring embedded webapplicationcontext2021-03-05 18:11:33.721 info 3704 --main] w.s.c.servletwebserverapplicationcontext : root webapplicationcontext: initialization completed in 5133 ms2021-03-05 18:11:34.797 info 3704 --main] o.hibernate.jpa.internal.util.loghelper : hhh000204: processing persistenceunitinfo [name: default]2021-03-05 18:11:34.902 info 3704 --main] org.hibernate.version : hhh000412: hibernate orm core version 5.4.28.final2021-03-05 18:11:34.983 info 3704 --main] o.hibernate.annotations.common.version : hcann000001: hibernate commons annotations 2021-03-05 18:11:35.266 info 3704 --main] org.hibernate.dialect.dialect : hhh000400: using dialect: org.hibernate.dialect.mysqldialect2021-03-05 18:11:36.838 info 3704 --main] o.h.tuple.entity.entitymetamodel : hhh000157: lazy property fetching **ailable for: org.springframework.samples.petclinic.owner.owner2021-03-05 18:11:37.094 info 3704 --main] o.h.e.t.j.p.i.jtaplatforminitiator : hhh000490: using jtaplatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.nojtaplatform]2021-03-05 18:11:37.112 info 3704 --main] j.localcontainerentitymanagerfactorybean : initialized jpa entitymanagerfactory for persistence unit 'default'2021-03-05 18:11:38.696 info 3704 --main] o.s.s.concurrent.threadpooltaskexecutor : initializing executorservice 'applicationtaskexecutor'2021-03-05 18:11:40.604 info 3704 --main] o.s.b.a.e.web.endpointlinksresolver : exposing 13 endpoint(s) beneath base path '/actuator'2021-03-05 18:11:40.758 info 3704 --main] o.s.b.w.embedded.tomcat.tomcatwebserver : tomcat started on port(s): 8080 (http) with context path ''2021-03-05 18:11:40.783 info 3704 --main] o.s.s.petclinic.petclinicapplication : started petclinicapplication in 13.846 seconds (jvm running for 14.906) The app starts in about 14 seconds. As you can see, GraalVM includes the full JDK and can be used as a drop-in replacement for the existing JVM. To learn more about the optimization flags available for GraalVM, please refer to the documentation here. GraalVM has the ability to create self-contained executable binaries from your J**A applications that run extremely fast. GraalVM's precompilation of your j**a takes care of all application classes, dependencies, and runtime libraries, and eliminates the overhead and footprint of the jvm itself. However, some high-level language features, such as runtime and reflection, require additional configuration. Many microservices j**a frameworks, such as Micronaut, Helidon, and Quarkus, support the immediate creation of native images. 1.First, install the native image tool. These packages are available in OCI's yum repository, but are not installed by default.
In this tutorial, we're building an application using micronaut because micronaut uses dependency injection and a slice-oriented runtime instead of reflection. 2.Use the following command in micronautio launch, to get started:
3.Run the app and see how long it takes to launch on the JVM:
You should see an output similar to the following example:
The app starts in 755 milliseconds, which is impressive. 4.Now, build a native image of your application and compare the startup times:
It takes about 5 minutes to build a native image. Once the build is complete, the native image will be placed in the target directory and named after the project. 5.Run the native image.
You should see an output similar to the following example:
Native images can be started up more than 40 times faster, in just 18 milliseconds. The bottom line is that no matter how simple or complex your application is, GraALVM native images give you an immediate performance boost. Combined with the latest form factor of ARM-based computing and GraALVM Enterprise Edition, Oracle Cloud Infrastructure provides an unmatched platform for building and growing your enterprise workloads. As an Oracle Premier Partner, Agilewing has revolutionized the way users experience Oracle Cloud Services. Agilewing provides a simplified account opening process and first-class technical support, so that users do not need to have a complicated and cumbersome account opening process, as well as complex operations. One-stop service, quickly complete the opening and activation of cloud services, and you can easily obtain various services of Oracle Cloud. AgileWing's AgileCDN integrated CDN service is perfectly combined with OCI cloud basic services to provide global content acceleration solutions for business internationalization. Customers can enjoy network efficiency and stability from more than 2,800 global POP nodes and more than 7,000 direct connection points. This means that no matter where your business is located in the world, Agilewing ensures that it runs efficiently. Agilewing leverages the advantages of Oracle Cloud to help build cloud services, migrate clouds, and expand your business overseas, eliminating the need for the complex process of researching and exploring Oracle Cloud Services on your own. This partnership model provides customers with a cost-effective solution that allows them to focus on their core business while enjoying the high performance and security of Oracle Cloud. Oracle Cloud Services is an area of potential, with high performance, security, and globally consistent service standards that offer endless possibilities. With Agilewing's professional services, users and enterprises alike can easily enter this new world and take advantage of all the benefits of Oracle Cloud. Start your Oracle Cloud Services journey now with Agilewing and explore this new era of innovation and performance.