NOTE
This file was generated by Descript <www.descript.com>
1

00:00:00,219  -->  00:00:01,840
Hi guys, and welcome back.

2

00:00:01,900  -->  00:00:04,779
In this video, let's talk
about Heroku real quick.

3

00:00:04,779  -->  00:00:07,210
What is it and why it exists?

4

00:00:07,600  -->  00:00:10,240
So what happens when
we run our flask apps?

5

00:00:10,780  -->  00:00:16,690
We know that when we type flask run on our
console, something starts and suddenly we

6

00:00:16,690  -->  00:00:22,960
can start making requests to 127.0.0.1,
colon 5000 and things start to happen.

7

00:00:23,740  -->  00:00:27,520
What's happening is a development
server starts and we're able

8

00:00:27,520  -->  00:00:29,500
to listen to incoming requests.

9

00:00:29,500  -->  00:00:34,150
So there is a piece of software there that
when we make a request using a browser

10

00:00:34,150  -->  00:00:39,310
or something similar, to the address,
then it intercepts that, and it gives it

11

00:00:39,310  -->  00:00:43,330
to the flask app, which deals with them
and responds appropriately with whatever

12

00:00:43,330  -->  00:00:45,640
data we've coded it to respond with.

13

00:00:46,236  -->  00:00:47,976
But here's the thing about deployments.

14

00:00:48,278  -->  00:00:53,438
And that is this question who can make
requests to our app when we run it?

15

00:00:54,278  -->  00:00:58,478
And the answer is anyone that has access
to the computer that's running the app.

16

00:00:58,928  -->  00:01:04,118
So if you run the app in your computer,
then anybody who has access to connect

17

00:01:04,148  -->  00:01:09,818
to your computer via the internet or
any network, then they will be able to

18

00:01:09,818  -->  00:01:15,878
make requests to the app if you know
how to do it, but it's not so easy.

19

00:01:15,908  -->  00:01:19,628
Most computers are not set up to be
accessible easily from the outside.

20

00:01:20,303  -->  00:01:24,293
And when you run your flask app,
that it defaults to only being

21

00:01:24,293  -->  00:01:26,453
accessible to your computer.

22

00:01:26,463  -->  00:01:28,613
Nobody else can make any requests.

23

00:01:28,913  -->  00:01:33,683
And even if you set up the flask app so
that it will listen to requests coming

24

00:01:33,683  -->  00:01:37,673
from elsewhere, other than your computer,
it is very likely that your computer

25

00:01:37,673  -->  00:01:41,858
is not set up to be able to accept
incoming requests from the outside.

26

00:01:42,188  -->  00:01:44,018
And that it's mostly for security reasons.

27

00:01:44,048  -->  00:01:47,108
You don't want random people to be
making requests to your computer.

28

00:01:47,768  -->  00:01:52,428
And, but also there is a practical
reason, which is that every internet

29

00:01:52,428  -->  00:01:57,588
connected device, such as your computer
or your phone, have an IP address and

30

00:01:57,648  -->  00:02:01,278
other internet connected devices can
use that IP address to connect to it.

31

00:02:01,428  -->  00:02:06,648
So computer B can connect to computer
A as long as it knows its IP address.

32

00:02:07,363  -->  00:02:11,163
But our ISP, our internet
service providers, normally do

33

00:02:11,163  -->  00:02:13,113
not provide fixed IP addresses.

34

00:02:13,143  -->  00:02:15,123
They provide dynamic IP addresses.

35

00:02:15,663  -->  00:02:19,893
So your computer's IP address today may
be different from the IP address tomorrow.

36

00:02:20,283  -->  00:02:23,973
And that is so that ISP's
can reuse IP addresses.

37

00:02:24,363  -->  00:02:27,043
When your computer goes offline,
they can give your an IP address

38

00:02:27,063  -->  00:02:28,263
to somebody else's computer.

39

00:02:28,533  -->  00:02:31,383
And then when they go offline, they
can give it to someone else and so on.

40

00:02:31,683  -->  00:02:34,233
So it's a cost cutting measure
in a way, and sometimes you

41

00:02:34,233  -->  00:02:36,183
can pay for a fixed IP address.

42

00:02:36,783  -->  00:02:37,893
So, obviously that's a problem.

43

00:02:37,923  -->  00:02:42,570
If you want to open up your computer
and you want to serve your app running

44

00:02:42,570  -->  00:02:46,693
in your computer, you need a fixed
IP address so that other people can

45

00:02:46,723  -->  00:02:51,763
connect to it and they don't have to
relearn your IP address every time that

46

00:02:51,763  -->  00:02:53,203
your computer restarts, for example.

47

00:02:53,631  -->  00:02:55,491
So why do we deploy our apps?

48

00:02:55,761  -->  00:02:58,041
Well, to circumvent these problems.

49

00:02:58,135  -->  00:03:03,335
When we deploy, we put our code, run it in
a computer that has a fixed IP address, is

50

00:03:03,335  -->  00:03:07,415
open to connections, has hardware that's
been specifically designed to be cheap and

51

00:03:07,415  -->  00:03:12,575
efficient when handling web applications,
and perhaps even more importantly, it

52

00:03:12,575  -->  00:03:16,565
is a computer that has been created
specifically to deploy our app.

53

00:03:16,895  -->  00:03:22,318
So we don't care if you know, somebody
hacks into it and causes some damage.

54

00:03:22,858  -->  00:03:24,848
We just destroy it and recreate it.

55

00:03:24,848  -->  00:03:26,588
And normally we can do that virtually.

56

00:03:26,858  -->  00:03:30,998
So there's a whole host of benefits to
deploy our apps on the internet with

57

00:03:30,998  -->  00:03:35,198
one of these server rental companies,
as I'll discuss in a moment rather

58

00:03:35,198  -->  00:03:37,028
than deploying it on your own computer.

59

00:03:38,213  -->  00:03:41,003
However, there are times where you do
want to deploy on your own computer.

60

00:03:41,033  -->  00:03:46,073
For example, you might buy a Raspberry
Pi and deploy a flask app in it

61

00:03:46,103  -->  00:03:50,813
and make it publicly accessible
within your private wifi network.

62

00:03:50,843  -->  00:03:54,653
Some people do that to make
APIs that they use within their

63

00:03:54,653  -->  00:03:56,303
home automation, for example.

64

00:03:56,843  -->  00:04:00,263
So these are things you can do because
at the end of the day, when you deploy

65

00:04:00,263  -->  00:04:03,203
your app, all you're doing is you're
grabbing your code and you're running

66

00:04:03,203  -->  00:04:07,733
it in a computer that is open to
connections and has a fixed IP address.

67

00:04:07,823  -->  00:04:10,853
And you can do the same with your
private network if you know how.

68

00:04:11,243  -->  00:04:13,493
We're not going to learn how to
do that in this course, we're just

69

00:04:13,493  -->  00:04:16,043
going to learn how to deploy online.

70

00:04:16,853  -->  00:04:18,803
So the payments to Heroku.

71

00:04:19,013  -->  00:04:22,613
Heroku is a server rental
company, basically.

72

00:04:22,823  -->  00:04:28,503
There's many like it, for example,
Google Cloud, or AWS, DigitalOcean,

73

00:04:28,823  -->  00:04:33,323
and lots more, and what they do
is, they rent out their computers.

74

00:04:33,483  -->  00:04:36,003
That they called servers since
they are used for serving

75

00:04:36,003  -->  00:04:37,863
data, they rent them out to us.

76

00:04:37,893  -->  00:04:38,943
We can rent them.

77

00:04:38,943  -->  00:04:44,803
And then we get access to a small,
very cheap server that we can use

78

00:04:44,803  -->  00:04:47,323
to put our code and run our app
and connect it to the internet.

79

00:04:47,983  -->  00:04:50,803
In Heroku, the servers are called
the Dynos, but they're really

80

00:04:50,803  -->  00:04:53,423
just computers running our code
and connected it to the internet.

81

00:04:53,443  -->  00:04:55,633
So you're going to see the
term Dyno here and there.

82

00:04:56,333  -->  00:05:00,146
Heroku gives us also a domain
name for every app that we deploy.

83

00:05:00,236  -->  00:05:04,826
For example, teclado dash microblog
dash app dot herokuapp.com

84

00:05:05,246  -->  00:05:06,626
instead of an IP address.

85

00:05:06,656  -->  00:05:09,626
That's just so it's easier to
share our pages with other people.

86

00:05:10,196  -->  00:05:14,306
If you only have an IP address, giving
that to someone else looks a bit weird.

87

00:05:14,426  -->  00:05:16,676
So getting a domain name is helpful.

88

00:05:17,043  -->  00:05:19,713
So what else does Heroku do other
than take our code and run it?

89

00:05:20,778  -->  00:05:24,588
Well, they do everything they can to
make money by making it easy for us to

90

00:05:24,588  -->  00:05:28,068
deploy our applications and make sure
that we continue to use their services.

91

00:05:28,366  -->  00:05:32,136
Do note that Heroku has a free plan,
so we don't have to pay for most of it.

92

00:05:32,376  -->  00:05:36,726
But the idea is that as we use
Heroku more and more, we want more

93

00:05:36,726  -->  00:05:39,066
and more of their services and
we'll end up paying money for it.

94

00:05:39,156  -->  00:05:41,316
That's that's the general premise
of any business, of course.

95

00:05:41,650  -->  00:05:45,430
So Heroku makes it easy to put our
code in their servers with one click.

96

00:05:45,460  -->  00:05:47,050
You can do that, which is great.

97

00:05:47,690  -->  00:05:49,820
They run our flask apps continuously.

98

00:05:49,850  -->  00:05:53,450
They restart them if they crash or they
restart the server if there's an error.

99

00:05:53,870  -->  00:05:58,310
They let us see the flask app logs and
error so we can debug them very easily

100

00:05:58,910  -->  00:06:00,410
and they handle a lot more stuff.

101

00:06:01,510  -->  00:06:05,560
Heroku also has Add-ons, which
add more functionality to Heroku.

102

00:06:05,590  -->  00:06:09,490
For example, it can create databases
for our apps and it can help

103

00:06:09,490  -->  00:06:13,630
us find errors more easily with
debug functionality and so forth.

104

00:06:13,980  -->  00:06:15,910
Theredozens of add-ons for Heroku.

105

00:06:16,090  -->  00:06:18,100
And we can even create
our own if we know how to.

106

00:06:19,360  -->  00:06:22,690
Everything that Heroku does is
done to make the deployment and

107

00:06:22,690  -->  00:06:26,650
maintenance job easier, deploying
the servers and maintaining them,

108

00:06:26,770  -->  00:06:28,300
keeping them up to date and so on.

109

00:06:28,627  -->  00:06:32,261
Heroku has a generous free plan,
like I mentioned, but it is limited

110

00:06:32,261  -->  00:06:35,651
to a thousand hours per month shared
between all your free projects.

111

00:06:35,681  -->  00:06:40,001
So if you have a lot of different free
projects in your Heroku account, they

112

00:06:40,001  -->  00:06:45,161
will be turned off once you reach the
1000 hour limit of the servers being up.

113

00:06:46,061  -->  00:06:49,241
After that the cost is
from $7 a month per Dyno.

114

00:06:49,251  -->  00:06:54,641
So if you have 10 projects and 10 dynos
and they're all in the 7 dollar a month

115

00:06:54,641  -->  00:06:57,011
plan, obviously you'd pay $70 per month.

116

00:06:57,431  -->  00:07:00,161
They have much more
expensive Dynos as well.

117

00:07:00,401  -->  00:07:03,811
And they are usually used for things
that need a lot of performance.

118

00:07:04,921  -->  00:07:05,911
So is it worth it?

119

00:07:06,031  -->  00:07:08,071
This is really the key question, right?

120

00:07:08,225  -->  00:07:13,175
Why would you pay for example, $500
a month for one Heroku Dyno in its

121

00:07:13,175  -->  00:07:18,445
most expensive format when you can
potentially buy your own computer

122

00:07:18,445  -->  00:07:22,495
for that money and set it up so
it runs online from your house.

123

00:07:23,485  -->  00:07:25,075
And, and do it that way.

124

00:07:25,855  -->  00:07:27,565
Well, Heroku does a lot for you.

125

00:07:28,315  -->  00:07:31,815
If you have the time, time to do the
things that Heroku does for you, then you

126

00:07:31,815  -->  00:07:35,175
could rent a cheaper server or even buy
your own computer and run your apps there.

127

00:07:36,105  -->  00:07:39,885
But the time saving from
using Heroku may be worth it.

128

00:07:40,305  -->  00:07:43,998
If that means that you can spend that
time doing something else, or sometimes,

129

00:07:44,058  -->  00:07:47,208
that may mean that you don't have to
hire somebody to do those things as

130

00:07:47,208  -->  00:07:48,408
that can be very expensive as well.

131

00:07:49,453  -->  00:07:52,153
However Heroku is known to
be relatively expensive.

132

00:07:52,273  -->  00:07:54,343
So that's something to keep
in mind that there are cheaper

133

00:07:54,343  -->  00:07:55,963
options available as well.

134

00:07:56,023  -->  00:07:59,143
Heroku is just really easy
to use and very convenient.

135

00:07:59,908  -->  00:08:03,808
Some of the things that Heroku does for
you that you probably don't want to do

136

00:08:04,318  -->  00:08:09,628
are things like handle operating system
updates in your servers, restarting apps

137

00:08:09,778  -->  00:08:13,408
and  the servers themselves if they crash
or they have any problem, provisioning

138

00:08:13,408  -->  00:08:18,148
databases, patching security issues
in your operating systems, handling

139

00:08:18,178  -->  00:08:22,768
SSL certificates so your websites are
secured, automatic scalability, things

140

00:08:22,768  -->  00:08:26,638
like if you get a sudden surge in users
accessing your page, they can provision

141

00:08:26,638  -->  00:08:31,198
more Dynos for you so that you can handle
the traffic and then scale back once

142

00:08:31,228  -->  00:08:33,898
the surge is over and a lot more stuff.

143

00:08:34,693  -->  00:08:38,143
So these are things that are
simply not easy to do manually.

144

00:08:38,143  -->  00:08:40,243
And if you have to do them, you have
to spend a lot of time doing them.

145

00:08:40,273  -->  00:08:44,023
So that is the trade-off there as
to whether it's worth it or not.

146

00:08:45,243  -->  00:08:48,963
So I'm going to show you Heroku, not
because I expect you to end up paying $500

147

00:08:48,963  -->  00:08:52,563
a month for a server, but because if you
want to deploy your apps and share them

148

00:08:52,563  -->  00:08:57,353
with your employers or your users quickly,
there's no easier way than using Heroku.

149

00:08:57,543  -->  00:09:00,673
So if you're working on a prototype or
a new project or something like that

150

00:09:00,673  -->  00:09:02,343
and you just want to get it out there.

151

00:09:03,058  -->  00:09:06,311
Get it on Heroku takes 10
minutes, if that, once you

152

00:09:06,311  -->  00:09:07,211
know how to do it, of course.

153

00:09:07,541  -->  00:09:09,721
And then it's online and
it's freely available.

154

00:09:09,901  -->  00:09:11,251
The free tier is very generous.

155

00:09:11,251  -->  00:09:12,511
You can use it for many things.

156

00:09:12,511  -->  00:09:15,931
I've used the free tier in
Heroku for years with my account

157

00:09:16,351  -->  00:09:17,941
and, and it's great, you know.

158

00:09:17,941  -->  00:09:21,781
Sometimes you go up to the paid tier for
specific projects if you really need to.

159

00:09:21,991  -->  00:09:23,521
But other than that, you
can use the free tier.

160

00:09:24,091  -->  00:09:27,571
And the finally it's going to look great
in your portfolio, if you deploy your

161

00:09:27,571  -->  00:09:31,981
web apps, if you give your employers your
code, that's going to be a great step.

162

00:09:32,011  -->  00:09:36,031
But if you can show that you also know
how to deploy it and share it with users,

163

00:09:36,271  -->  00:09:38,341
that's a massive step forward as well.

164

00:09:38,641  -->  00:09:40,151
So this is what I'm
going to show you Heroku.

165

00:09:40,261  -->  00:09:43,621
It's easy, straightforward, it's
good, and it's going to look great

166

00:09:43,741  -->  00:09:44,971
when you have your apps deployed.

167

00:09:45,766  -->  00:09:48,196
So thank you guys for joining me in this
video now that you know a little bit

168

00:09:48,196  -->  00:09:52,876
more about what Heroku is, let's get
started with Heroku in the next one.

169

00:09:53,266  -->  00:09:53,866
I'll see you there.
