►
From YouTube: Utilising MicroProfile Healthchecks in a cloud environment | Jakarta Tech Talks - March 2020
Description
MicroProfile Health is an API designed specifically for use in cloud and containerized environments, where you want to quickly determine if an instance of an application is unhealthy and restart it. How exactly do you use it though? In this session, I’ll run through how to add some health checks to your application, and how to configure a number of cloud providers and containers to effectively use them to restart your application instances.
A
B
Me
clearly,
all
right
so
yeah
my
name
is
Andrew
pH.
This
is
my
cat
profile
health
cloud
demo,
showing
give
me
a
quick
overview
of
using
micro
file,
health
in
a
cloud
environment.
So
there's
my
details:
I'm
a
Java
developer
at
PI,
R
services
contact
me
on
Twitter.
There,
though
I'll
never
look
at
it.
B
So
just
a
little
bit
of
background
first,
so
proud
obviously
has
essentially
become
the
industry
trend
in
recent
years
for
hosting
you
web
applications
right
in
comparison
to
hosting
them
on-premises
on
so
literal
hardware,
you
have
in
your
office
or
in
a
server
rack
somewhere.
The
reasoning
for
that
is,
there's
a
numerous
ones,
but
it's
got
a
lower
bar
of
entry
because
you
don't
actually
have
to
spend
thousands
of
pounds
or
dollars
on
buying
out
a
massive
server
rack
and
setting
it
all
up.
B
That's
not
to
say
that
cloud
is
necessarily
cheaper
depending
how
you
use
it.
It
can
be
more
expensive,
it's
cheaper
with
asterisks,
but
it
brings
various
other
benefits
as
well,
such
as
easier
setup
and
maintenance
easiest
staling,
just
because
of
the
fact
that
it's
all
done
essentially
via
interface
and
the
various
cloud
platforms
are
actually
dealing
with
all
the
groundwork
for
you.
B
B
B
It's
not
always
necessarily
a
good
thing
to
be
using
microservices,
particularly
if
you're
actually
moving
across
from
an
existing
monolithic
app.
There
are
many
pitfalls
which
are
frequently
fallen
into
the
biggest
one,
probably
just
being
that
you
are
moving
from
a
monolithic
app
to
a
micro-services
architecture.
They
are
not
one
in
the
same.
It's
not
easy
at
all
to
switch
from
one
to
the
other,
just
because
the
the
design
is
very
different.
B
But
micro-services
they,
as
mentioned
they're,
smaller,
more
focused.
They
allow
you
to
more
easily
kind
of
just
develop
individual
parts
and
of
your
application
independently
and
even
deploy
them
independently,
because
that's
the
actual
intent
behind
it
so
you've
got
multiple
bits
of
your
application
of
your
greater
application
deployed
independently.
B
So
monitoring
of
those
is
can
be
quite
complicated.
It's
one
of
the
age-old
problems
with
actually
running
systems
and
applications
in
production
of
how
do
you
know
when
it's
going
wrong
or
gone
wrong?
So
one
of
one
of
the
main
ones
which
you're
probably
all
familiar
with
is
simply
just
the
Machine
health
of
is
it's
at
a
100%
CPU
usage?
Is
it's
at
100%,
RAM
usage
or
as
the
storage
completely
filled
up
a
lot
of
those
metrics
are
actually
provided
by
the
cloud
providers
such
as
AWS.
B
They
frequently
have
basic
levels,
which
is
normally
free
or
just
extremely
cheap,
which
is
quite
literally
there.
It's
set
at
100%,
CPU
usage
and
then
you've
they
typically
provide
more
in-depth
ones
as
well,
but
in-depth
ones
typically
have
some
sort
of
link
into
notifications,
which
is
the
second
way
of
monitoring
of
a
you've.
Once
you've
got
your
monitoring
set
up,
how
do
you
actually
know
about
it?
How
do
you
get
notified
of
it
again?
B
Most
of
the
cloud
providers
give
some
sort
of
notification
system,
and
if
they
don't,
one
of
the
common
ways
is
just
simply
within
the
application.
Server
itself
set
up
notifications
as
most
have
some
form
of
emailing,
you
or
otherwise,
notifying
you,
but
this
leads
me
nicely
into
from
application
service
to
the
actual
applications.
B
You
can
literally
just
see
the
time
out
of
oh
when
you
hit
the
actual
end
point
or
it's
just
being
extremely
slow,
and
so
literally
you
try
to
use
the
app
and
it's
not
there
he's
a
form
of
monitoring
in
their
sense,
I
already
mentioned,
there's
application
server
metrics
this
tends
to
be
things
like
thread
pools,
so
you've
got
a
bit
more
fine-grained
knowledge
of
what's
happening
of
why
your
applications
potentially
not
responding,
such
as
the
thread
pools,
are
completely
filled
up
and
those
typically
can
be
exported
into
third-party
monitoring
solutions.
Such.
B
Micro
profile
is
just
kind
of
its
own
thing
within
eclipse,
where
it's
a
lot
easier
and
it's
a
lot
quicker
moving
and
it's
not
tied
to
Oracle
of
obviously
Java
EE
is
now
moved
over
to
eclipse
and
is
now
Jakarta
EE,
but
that
does
not
necessarily
mean
that
micro
profile
is
moving
back
in
Swift
at
all.
If
anything,
the
my
I've
heard
through
the
grapevine
it's
very
much
going
to
be
staying
separate
from
Jakarta
EE
they're.
Quite
some
strong
opinions
that
it
should
remain
separate.
It
should
remain
faster-moving,
but
still
it
keeps
using
it.
B
So
micro
profile,
it's
as
its
name
alludes
to-
is
very
much
designed
around
designed
around
giving
application
developers
and
a
PR
a
PR
various
api's
for
actually
developing
micros,
a
patient's
from
micro
service
architectures.
One
of
these
is
micro
profile,
health,
which
was,
although
not
all
of
them,
are
designed
for
using
cloud
and
containerized
environment
Mike
profile.
Health.
Most
definitely
was
it's
quite
closely
tied
to
Cuban
et's
and
the
other
cloud
providers.
B
In
that
it
gives
you
an
API
which
lets
you
define
various
checks
that
you
can
trigger.
So
it
gives
three
different
at
the
moment.
It
gives
three
checks
in
future.
This
will
probably
go
be
dropping
down
to
two.
It
provides
readiness,
checks,
liveness
checks
and
then
generic
they
didn't
really
have
a
name.
They
were
just
called
health
checks,
but
they
were
just
generic.
Those
are
the
ones
which
are
deprecated.
Readiness
checks
are
intended
to
be
used,
as
essentially
is
your
application
started.
Is
it
running?
Is
it
actually
ready
to
be
begins?
B
B
B
So
a
little
example
so,
rather
than
just
me,
staying
here's
a
I've
written
up
a
very,
very
basic
health
check
who
specified
this.
You
should
not
be
writing
a
health
check
like
this
at
all,
I'll
be
using
this
in
the
demo
today.
But
this
essentially
you
define
your
health
jet.
You
implement
the
health
check
interface
for
your
class
in
the
case
of
CDI
scoping.
B
It
needs
to
be
scopes
to
see
the
ISO
in
this
case,
I've
just
done
its
application
script
and
then,
depending
on,
if
you
want
it
to
be
a
liveness
check
or
a
readiness
check,
you
annotate
it
with
liveness
already
less,
you
can
actually
provide
specify
a
check
as
being
both.
What
that
simply
means
is
that
if
you
hit
the
health
ready
endpoint,
it
will
appear
there
and
also,
if
you
hit
the
health
live
endpoint,
it
will
appear
there
as
well.
B
So
this
with
data
method,
it's
not
just
string.
If
you
wish,
you
can
provide
Long's
billions
of
strings.
Essentially,
you
can
just
fill
it
out
with
as
much
metadata
as
you
want,
and
then
the
up
is
used
to
define
that
everything
is
healthy
and
down
is
used
to
define
that
everything
is
down
essentially
not
healthy.
B
B
More
useful
ones
would
be
ones
utilizing
actual
life
and
us
checks
around.
Did
it
respond
within?
Let's
say:
did
it
respond
within
five
seconds
or
something
like
that?
You
can
define
that
in
your
application
or
you
could
define
that
in
the
cloud
of
did
it
actually
respond,
so
the
original,
if
you
want
to,
if
you're,
coming
from
the
older
versions
of
the
API,
there
is
still
the
health
endpoint,
as
you
can
see
there
at
across
that
because
it's
deprecated
as
I
said
no,
this
is
the
generic
one.
B
A
B
The
endpoint,
as
I
mentioned,
is
under
health,
so,
if
I
hit
health,
this
would
run
through
every
single
check.
This
would
run
through
all
low
finished
checks
and
all
readiness
checks.
I've
only
got
the
one
in
this
application,
but
you
can
see
here.
The
coin
flip
went
well,
I
got
a
heads,
essentially,
so
it's
giving
a
status
of
up.
So
this
is
in
Jason
as
well.
So
if
you
want
to
read
through
it
using
a
jsonparser,
you
can,
which
is
the
actual
use
of
the
meta
data.
B
B
B
B
A
B
The
API
is
well,
was
designed
around
not
necessarily
supporting
multiple
applications,
although
it
does,
in
the
case
piyo
micro,
so
in
the
same
manner
that
there's
no
way
of
going
give
me
all
of
the
liveness
checks
for
the
application
one
and
excludes
the
other
deployed
applications.
There
is
no
way
of
doing
that.
It
gives
it
searches
through
all
the
deployed
applications
and
gives
you
the
runs
the
health
checks
for
all
of
them.
As
I
said,
this
is
a
micro.
B
A
B
B
This
returns
an
HTTP
503,
which
hopefully
we'll
see
you
later,
but
that's
it's
just
to
say
it's
unavailable.
If
you
don't
really
don't
remember
your
HTTP
status
codes
off
the
top
of
your
head,
I
should
also
mention
as
well
that
when
it
runs
through
all
of
the
various
status
checks,
it
will
only
give
an
upstate
if
all
of
them
return
true,
so
because
I've
only
got
one.
These,
the
general
status
of
up
will
mirror
what
the
status
of
this
one
is
here.
B
If
one
of
them
returns
down,
then
the
entire
application
is
determined
to
be
unhealthy.
So
you
need
to
bear
that
in
mind
when
you're
defining
your
health
checks
that
they
need
to.
You
need
to
be
careful
that
you're,
not
necessarily
including
a
fragile
health
check
like
this,
when
it
doesn't
necessarily
need
to
be
there.
B
Just
a
very,
very,
very
basic
demo
of
setting
up
a
ADA,
an
example
environment
in
AWS,
showing
off
as
this
application
of
how
to
use
the
health
live
endpoint
in
the
case
of
load
balances,
I'm
not
going
to
be
covering
doing
any
thing
clever,
such
as
removing
dead
instances
and
replacing
them
with
healthy
ones.
That's.
B
Of
this,
this
is
Julie
is
going
to
be
the
very
basics
of
getting
people
started
so
from
the
AWS
console.
The
very
first
step
we
need
to
do
is
simply
actually
create
your
ami,
because
I'm
going
to
be
using
scaling
and
I
want
to
define
my
ami
before
I
use
it
rather
than
having
it
defining
all
the
young
installs
per
instance.
A
B
And
then
for
a
security
group
I'm
going
to
give
it
one
I
made
earlier
for
those
who
weren't
aware
the
security
groups
they're.
Essentially
just
it's
a
firewall
configuration
essentially,
if
you
define
what
ports
can
access
it
from
where
so.
In
this
case,
I've
made
a
very
simple
one
of
port
80,
so
default
HTTP
can
be
accessed
from
anywhere
and
also
port
8080
can
also
be
accessed
from
anywhere.
This
is
the
default
port
that
power
micro
starts
on
and
then
just
anywhere.
My
IP
address
as
well.
B
B
A
B
B
Show
you,
it
is
very
most
nothing
there.
It's
just
a
few
basic
may
have
an
application
in
the
palm
I'm
just
grabbing
down
the
Jakarta
Web
API,
so
I've
got
access
to
the
various
CDI
annotations
and
then
I'm
also
taking
down
specifically
the
health
API,
because
that's
the
only
one
I'm
using
two
point
one.
The
latest
is.
A
B
B
B
A
B
So
I
said:
I
could
use
docker
for
this
we
do
provide
payara,
provides
a
base
pair
micro,
docker
image,
which
is
essentially
just
the
git
repo
is
here
at
pirate
occupy
Micra
is
on
docker
hub.
You
don't
have
to
necessarily
build
it
yourself,
but
if
you
do
want
to
deploy
your
own
application,
this
is
probably
better
to
build
your
own
thing
and
doing
so
is
really
simple.
Well,
yes,
you
could
take
the
full
docker
file
and
edit
it
to
your
heart's
content.
B
It
the
reason
I'm
not
using.
That
is
because,
as
I
said,
I'm
intending
for
this
to
be
building
the
latest
version
of
my
application
each
time
and
that's
not
in
the
spirit
of
docker
the
docker
instance,
docker
images
are
meant
to
be
fairly
static.
You're
not
meant
to
be
building
things
within
them.
Each
time.
A
B
B
And
create
the
image
from
it.
This
just
means
rather
than
me,
spinning
up
the
new
instance
and
having
to
do
that,
each
time
or
within
the
startup
parameters
of
the
instance,
specifying
that
I
can
just
literally
have
it
as
that.
So
this
can
potentially
make
the
actual
startup
time
of
your
instances
quicker,
because
they're
not
having
to
manually,
install
Java
maven,
get
and
then
build
your
application
or
even
download
your
application.
B
That's
typically
another
issue
you
have
if
your
application,
for
example,
is,
let's
just
say,
two
gigabytes
in
size,
if
you're
just
using
the
startup
scripts,
if
you're
just
defining
your
instances
to
start
and
download
that
application
each
time,
you
start
a
new
instance.
You've
got
to
download
that
that
two
gigabyte
application
that.
A
B
B
B
A
A
B
B
B
Group
again
I
want
to
Carter
Tech
Talk
so
that
I
can
actually
talk
to
it.
If
you
remember,
I
was
opening
port
8080
and
port
80.
This
is
important
because
if
port
8080
wasn't
open
or
whichever
port
payara
micro
is
running
on,
this
style
wouldn't
work,
because
I
wouldn't
actually
be
able
to
hit
the
Health
endpoint
or
even.
A
A
B
B
B
Configuration
itself
or
configuring
anything
with
an
AWS
I'm,
just
going
to
tell
it
to
go
to
the
health
endpoint
and
then,
as
part
of
my
normal
app
development,
I've
written
the
health
check
that
I
want
where
I
can
actually
access
the
internals
of
my
application.
So,
for
example,
if
I'm,
let's
say
I
had
a
a
fixed
boundary
and
for
some
reason,
I
wanted.
A
health
check
of
just
going
back
array
is.
A
B
Do
that,
but
the
option
is
there
if
you
do
want
to
do
it,
so
the
healthy
threshold
is
number
of
consecutive
health
checks
that
want
something
is
considered
unhealthy
for
it
to
become
healthy
again.
As
said,
this
is
not
dealing
with
replacing
unhealthy
instances.
This
is
simply
just
marking
instances.
B
B
A
A
B
So
selecting
the
template
version
the
way
Amazon
works
is
you
can
actually
keep
referencing
different
versions
of
your
launch
template,
so
by
default
it
picks
the
default.
The
default
does
not
change
how
the
default
is
not
necessarily.
The
latest
default
is
just
by
default,
the
very
first
one
there.
If
you
want
to
change
the
default
or
only
use
the
latest
either
pick
latest
or
change
your
default
each
time.
B
A
B
B
A
B
A
A
B
So
because
of
the
fact
that
I
am,
as
I've
mentioned,
doing
a
coin
flip,
this
is
the
version
of
the
application
I'm
using
as
well.
So
it's
a
slightly
weighted
coin
flip,
but
it
is
still
essentially
a
coin
flip
and
the
fact
that
I
set
the
health
checks
to
be
quite
harsh
I
need
it
to
pass
five
times
in
a
row.
It
will
be
quite
hard
for
it
to
move
out.
B
A
B
So
further
usages
as
I
meant.
Obviously
this
is
not
just
limited
to
AWS
just
for
pure
time
constrict
restrictions.
That's
all
I
had
time
to
very
quickly
show
in
such
detail,
but
it
this
should
definitely
work.
In
fact,
it
not
should
work,
it
does
work
in
Xero
and
there
are
options
in
Cuban,
ETS
and
docker
swarm.
The
readiness
checks,
in
particular
the
or
the
differentiation
between
liveness
and
ready
check
the
readiness
checks
that
comes
more
into
focus
in
communities
and
docker
swarm
where
they
actually
have
separate
checks
for
that
of
going.
B
B
B
So,
as
I've
mentioned
multiple
times
in
this
as
well,
you
can
automatically
replace
unhealthy
instances.
That
is
probably
one
of
the
main
usages
for
it,
along
with
avoiding
the
unhealthy
instances
if
I
didn't
have,
if
I
wasn't
using
the
slash
health,
endpoint
I'd
have
to
be
providing
some
other
means
of
telling
the
load
balancer
how
to
know
if
it's
healthy,
so.
B
Just
in
a
very
dumb
way
you
could
have
I
could
have
not
had
it
directed
at
the
health.
The
health
patch
I
could
have
had
it
just
pointed
straight
at
this
index
page
and
then
gone
that
got
off
server.
500
error
that
didn't
work
and
use
that
as
the
health,
that's
quite
E,
brutal
and
dumb
check,
though
of
just
going
is
the
application
working
yes
or
no,
with
the
health
checks
with
liveness
and
readiness,
you've
got
more
flexibility
and
more
control
over
how
that
works,
particularly
if
you
start
using
multiple
those
liveness
checks.
B
As
I
mentioned,
you
can
specify
multiple
ones,
but
you
can
combine
it
with
the
machine,
health
and
various
other
metrics.
As
I
mentioned,
you
can
access
things
within
your
application,
so
you
could
say:
can
the
application
itself
contact
the
database
that
you've
got?
Can
it
do
a
ping
kind
of
do
it
get?
Is
it
actually
returning
data
because
you
can
be
CDI
scoped?
It's
got
full
access
to
all
the
other
beams
and
stuff,
so
you
can
check
if
your
beans
are
actually
returning
things
as
mentioned,
you
can
combine
it
with
machine
health.
B
You
can
either
set.
We
combined
that
separately,
define
on
the
in
a
DBS
or
in
your
cloud
provider.
General
of
just
is
it's
at
a
hundred
percent
CPU
usage
for
five
seconds.
Okay,
that's
wrong,
but
then
also
have
this.
Alternatively,
you
could
use
one
of
the
other
micro
profiler
specifications.
The
metrics
is
the
one
that
comes
to
mind.
This
is
specifically
around
getting
that
information
such
as
CPU
usage
and
stuff.
B
So
within
your
health
check,
then
have
the
dependencies
downloaded
at
the
time,
but
I
could
get
the
metrics
registry
within
my
health
check
here
and
start
doing.
Those
calls
and
querying
the
the
machine
State,
but
also
the
application
steak
is
the
metric
micro
profile.
Metrics
is
not
purely
limited
to
the
machine
metrics.
It
does
give
you
access
to
other
things
as
well,
such
as
how
frequently
how
how
frequently
something
is
being
hit,
among
other
things
as
well
gives
you
quite
a
vast
amount
of
different
metrics
that
you
can
query
from
here.
B
A
A
B
A
B
B
B
You
don't
necessarily
if,
in
the
case
of
as
I
had
in
this
example,
have
the
IP
public.
You
don't
necessarily
want
everybody
else
to
be
able
to
check
the
state
of
your
application,
particularly
if
you're
sending
said
sensitive
metadata
over
the
wire,
because
you
can
add
anything
you
want
in
there.
So,
if
you're
being
a
bit
thick
and
sending
your
passwords
as
plain
text
that
should
be
protected
and
yes
by
default,
the
health
endpoint
is
not
protected.
A
B
Going
to
say,
no
I,
don't
think
that
should
probably
be
in
there
if
nothing
else,
just
because
then
you're
starting
to
bleed
over
specks
a
bit.
You
know
as
mentioned,
although,
yes,
there
is
the
availability
of
you
checking
the
information
yourself
when
you
start
bringing
in
authentication,
particularly
for
things
such
as.