-
Notifications
You must be signed in to change notification settings - Fork 3k
serverless.adoc #1192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
serverless.adoc #1192
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2070dae
start the serverless docs
188d637
first draft of serverless doc
f610b42
slight expansion on the runnable jar
d5f5da6
Update docs/src/main/asciidoc/topic/serverless.adoc
gastaldi 771ca67
Update docs/src/main/asciidoc/topic/serverless.adoc
gastaldi 4334607
missing a word
58cc1a1
Update docs/src/main/asciidoc/topic/serverless.adoc
gastaldi fe25588
PR feedback updates
efe2fa8
break out sentences to separate lines
6b2b093
add a bit explaining serverless.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| == Functions as a Service and Serverless | ||
|
|
||
| Functions as a Service and, more broadly, serverless is an emerging trend that is gaining wide adoption with offerings from most of the | ||
| major platform and cloud providers. Owing much to the simplicity of the development model, more and more workloads are being deployed as | ||
| serverless functions to take advantage of the automatic scaling and concurrency that serverless offers. However, to date, Java and the | ||
| JVM has not been a primary focus for many. JVM startup time and memory overhead are prohibitive costs for many organizations. However, | ||
| it would be a shame to leave behind the wealth of experience and vast ecosystem in order to gain efficiencies in a serverless model. | ||
evanchooly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Quarkus solves of much of this for us. Quarkus offers blindingly fast start up times memory optimized applications well-suited to | ||
evanchooly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| serverless environments. With Quarkus, developers can continue to use Java and many of the libraries familiar to them. Quarkus takes on | ||
| the work of packaging everything up for deployment. | ||
|
||
|
|
||
| === Running a Quarkus app on serverless | ||
|
|
||
| One of the challenges when adopting serverless as development paradigm comes down to choice. There are many choices available to build | ||
| your functions and which one is chosen can have lasting impacts. Quarkus can help eliminate some of this by allowing you to bring | ||
| along the frameworks you know use and trust. While many FaaS offerings bring with them their own APIs one needs to implement in order to | ||
| function properly, many also offer the option to deploy arbitrary containers via Docker or OCI images. | ||
|
|
||
| Consider the following basic CRUD example: | ||
|
|
||
| [source, java] | ||
| ---- | ||
| @Path("/") | ||
| @ApplicationScoped | ||
| public class CRUDResource { | ||
|
|
||
| @Inject | ||
| EntityManager em; | ||
|
|
||
| @Inject | ||
| UserTransaction transaction; | ||
evanchooly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| @GET | ||
| @Produces(MediaType.TEXT_PLAIN) | ||
| @Transactional | ||
| @Path("/cake") | ||
| public String getCake() { | ||
| Cake c = (Cake) em.createQuery("from Cake").getSingleResult(); | ||
evanchooly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return c.getType(); | ||
| } | ||
| } | ||
evanchooly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ---- | ||
|
|
||
| Taking this simple GET operation, we can use quarkus to build a runnable jar or even an native image which we can then embed in a Docker | ||
evanchooly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
evanchooly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| image or for use in a Knative Build script for deployment on top of kubernetes. | ||
evanchooly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| [source, shell] | ||
| ---- | ||
| mvn package ## produces a runnable jar with dependencies in target/lib | ||
| ---- | ||
|
|
||
| or | ||
|
|
||
| [source, bash] | ||
| ---- | ||
| mvn quarkus:native-image ## produces a standalone executable | ||
evanchooly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ---- | ||
|
|
||
| The runnable jar can then be execute simply by running `java -jar target/myapplication-runner.jar`. Either scenario requires minimal work, | ||
evanchooly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
evanchooly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
evanchooly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| then, to bundle in to your preferred FaaS platform. | ||
|
|
||
| === FaaS API | ||
| All this begs the question: why doesn't Quarkus simply provide its own opinionated API? While this may happen eventually, the current | ||
| philosophy is to integrate what choices make sense so developers don't need to learn a whole new API set to make use of Quarkus. | ||
evanchooly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.