How to scale apps and cloud services for Play Magnus
This is a modal window.
Das Video konnte nicht geladen werden, da entweder ein Server- oder Netzwerkfehler auftrat oder das Format nicht unterstützt wird.
Formale Metadaten
Titel |
| |
Serientitel | ||
Anzahl der Teile | 170 | |
Autor | ||
Lizenz | CC-Namensnennung - keine kommerzielle Nutzung - Weitergabe unter gleichen Bedingungen 3.0 Unported: Sie dürfen das Werk bzw. den Inhalt zu jedem legalen und nicht-kommerziellen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen und das Werk bzw. diesen Inhalt auch in veränderter Form nur unter den Bedingungen dieser Lizenz weitergeben | |
Identifikatoren | 10.5446/50586 (DOI) | |
Herausgeber | ||
Erscheinungsjahr | ||
Sprache |
Inhaltliche Metadaten
Fachgebiet | ||
Genre | ||
Abstract |
|
NDC Oslo 201436 / 170
2
3
5
6
8
11
12
16
21
22
23
27
31
35
37
42
43
45
47
48
49
50
52
54
56
57
58
61
65
66
67
71
74
77
80
81
83
84
85
87
88
89
90
91
94
95
96
97
98
100
102
107
108
112
114
115
116
118
120
121
122
123
126
127
128
130
133
135
137
138
139
140
141
142
143
144
145
147
148
149
150
153
155
156
157
158
159
160
161
162
163
166
169
170
00:00
MaßstabApp <Programm>PunktwolkeDienst <Informatik>Architektur <Informatik>Zentrische StreckungSpieltheorieCodeComputerschachPhysikalisches SystemProjektive EbeneBitSoftwareentwicklerSystemaufrufZentrische StreckungSpieltheorieMereologieVideokonferenzQuick-SortComputerarchitekturWelleEinfach zusammenhängender RaumEchtzeitsystemSocket-SchnittstelleHybridrechnerProdukt <Mathematik>TypentheorieCASE <Informatik>Demo <Programm>Dienst <Informatik>DifferenteSystemverwaltungFlächeninhaltApp <Programm>Front-End <Software>InternetworkingBildschirmfensterKartesische KoordinatenEin-AusgabeCodierungGebäude <Mathematik>Rechter WinkelGüte der AnpassungDifferenzenrechnungSystemplattformBesprechung/Interview
03:45
SpieltheorieComputerComputerschachProgrammierungPhysikalische TheorieArchitektur <Informatik>SystemplattformMailing-ListeRechnernetzWellenlehreDienst <Informatik>CachingWeb SiteSQL ServerPasswortAbfragePunktwolkeGoogle AnalyticsGoogolInformationsspeicherungMobiles InternetSkalierbarkeitApp <Programm>Dienst <Informatik>SpieltheoriePhysikalisches SystemRechter WinkelTwitter <Softwareplattform>ComputerschachFacebookSchnittmengeMereologieSystemaufrufWellenpaketZeitzoneOffene MengeMultiplikationsoperatorQuick-SortSystemplattformAuthentifikationProjektive EbeneMobiles InternetLeistung <Physik>RahmenproblemGüte der AnpassungMAPVersionsverwaltungFlächentheorieGoogolFrequenzZweiSpeicherabzugSkalierbarkeitHypermediaSpezialrechnerBitPunktZentrische StreckungZusammenhängender GraphURLComputerspielStatistikVollständiger VerbandPhysikalischer EffektE-MailMailing-ListeVorzeichen <Mathematik>EreignishorizontWhiteboardHumanoider RoboterExistenzsatzHyperbelverfahrenEin-AusgabeBoolesche AlgebraREST <Informatik>Gebäude <Mathematik>
12:26
Data DictionaryZeichenketteClientOISCKanalkapazitätRechenwerkSystemaufrufMaß <Mathematik>MaßstabFreewareDienst <Informatik>Mobiles InternetSpieltheorieKomponente <Software>PunktwolkeInformationsspeicherungWarteschlangeNormierter RaumSystemplattformStochastische AbhängigkeitExogene VariableContent ManagementDatenverwaltungCodeZentrische StreckungBildschirmfensterUnternehmensarchitekturQuick-SortPortal <Internet>Leistung <Physik>RechenbuchMulti-Tier-ArchitekturSpezialrechnerCodeRechenzentrumMusterspracheDienst <Informatik>InstantiierungMereologieClientEin-AusgabeResultanteGreen-ITWort <Informatik>FunktionalEinfach zusammenhängender RaumZusammenhängender GraphArithmetische FolgePhysikalisches SystemBildschirmmaskeWarteschlangeLastBandmatrixMobiles InternetSystemplattformProjektive EbeneSpieltheorieDatenverwaltungBenutzerbeteiligungService providerDruckverlaufBus <Informatik>RechenwerkCASE <Informatik>Humanoider RoboterProzess <Informatik>PhasenumwandlungMultiplikationsoperatorVersionsverwaltungStochastische AbhängigkeitZahlenbereichInformationsspeicherungMailing-ListeStandardabweichungFlächeninhaltGemeinsamer SpeicherFlächentheorieWeb SiteMultipliziererElektronisches ForumPhysikalische TheorieMultiplikationRechter WinkelPunktExogene VariableSystemaufrufSkriptspracheGruppenoperationProgrammfehlerGeradeEchtzeitsystemPersonal Area NetworkMinkowski-MetrikPartikelsystemBitQuellcodeComputeranimation
21:06
Komponente <Software>Mobiles InternetCodeDienst <Informatik>ComputerschachSchlussregelCachingProgrammbibliothekMobiles EndgerätDatenmodellZeitbereichHydrostatikSoftware Development KitChi-Quadrat-VerteilungVersionsverwaltungATMInformationsmanagementLokales MinimumMagnettrommelspeicherEINKAUF <Programm>Witt-AlgebraZeichenketteDatenbankMobiles DatenbanksystemInstantiierungApp <Programm>InformationsspeicherungTabelleENUMMIDI <Musikelektronik>VakuumTermMobiles EndgerätZusammenhängender GraphMobiles InternetCachingCodeHalbleiterspeicherRechenbuchKlasse <Mathematik>HydrostatikMultiplikationsoperatorAggregatzustandProjektive EbeneDienst <Informatik>ProgrammbibliothekTeilmengeHumanoider RoboterPortabilitätGewicht <Ausgleichsrechnung>SoftwaretestSystemplattformMicrosoft dot netBitModallogikAusnahmebehandlungREST <Informatik>Endliche ModelltheorieBildschirmmaskeEinsComputerschachInstantiierungGemeinsamer SpeicherDatenbankInformationsspeicherungTabelleGüte der AnpassungVisualisierungProgrammierumgebungSchlussregelApp <Programm>ComputerarchitekturEin-AusgabeSpieltheorieSoftwareentwicklerSchreiben <Datenverarbeitung>Trennschärfe <Statistik>Front-End <Software>CASE <Informatik>EinflussgrößeHilfesystemSystemaufrufLastZentrische StreckungBildschirmfensterDifferenteQuaderDelisches ProblemComputerspielNotebook-ComputerSchnittmengeStörungstheorieCall CenterEinfache GenauigkeitMessage-PassingNummernsystemKlassengruppeGrenzschichtablösungGraphfärbungQuellcodeFlächentheorieWhiteboardDruckverlaufFigurierte ZahlComputeranimation
29:47
ComputerschachOvalSpieltheorieMAPWhiteboardProgrammbibliothekSchlüsselverwaltungMarketinginformationssystemPortscannerGemeinsamer SpeicherWindows PhoneHumanoider RoboterComputerCodePunktwolkeZellularer AutomatSichtenkonzeptWeb-SeiteTabelleInhalt <Mathematik>Betrag <Mathematik>Keller <Informatik>Mailing-ListeRahmenproblemWrapper <Programmierung>AppletZeitbereichDatenmodellDienst <Informatik>SchlussregelCachingArchitektur <Informatik>Disk-ArrayDemo <Programm>Elektronisches ForumWeb SiteReelle ZahlSkalierbarkeitSocket-SchnittstelleInformationsmanagementWellenlehreInstantiierungProjektive EbeneInternetworkingSoftwaretestEinfach zusammenhängender RaumProgrammbibliothekApp <Programm>VerschlingungEchtzeitsystemAggregatzustandRichtungCodeComputerschachInstantiierungDifferenteSchlussregelOrtsoperatorSichtenkonzeptCodierungSpieltheorieMereologieKlasse <Mathematik>Web SiteMailing-ListeGamecontrollerInverser LimesWarteschlangeWrapper <Programmierung>StichprobenumfangAppletKundendatenbankComputerarchitekturHackerAuswahlaxiomFormale SpracheGemeinsamer SpeicherCompilerThreadEndliche ModelltheorieSystemplattformBenutzerbeteiligungDemo <Programm>MultiplikationsoperatorProdukt <Mathematik>BeobachtungsstudieSchnittmengeForcingQuellcodeSystemaufrufProzess <Informatik>InformationsspeicherungPrinzip der gleichmäßigen BeschränktheitGreen-ITDruckspannungGüte der AnpassungNP-hartes ProblemSpeicherabzugComputeranimation
38:28
Web SiteReelle ZahlSkalierbarkeitAnwendungsdienstanbieterDienst <Informatik>Gewicht <Ausgleichsrechnung>Mobiles InternetWellenlehreBimodulKonfigurationsraumSchnittmengeDruckspannungSystemprogrammBenchmarkMessage-PassingDokumentenserverDemo <Programm>URLLokales MinimumSoftwareentwicklerPasswortEigentliche AbbildungComputerschachDienst <Informatik>SoftwaretestPunktReelle ZahlPrinzip der gleichmäßigen BeschränktheitKonfigurationsraumBitZusammenhängender GraphUnternehmensarchitekturInternetworkingInformationEinfach zusammenhängender RaumModallogikBenutzerbeteiligungCASE <Informatik>CodeDemo <Programm>VersionsverwaltungBus <Informatik>FacebookMessage-PassingInstantiierungServerPhysikalisches SystemMereologieSocketGeradeZahlenbereichQuaderMobiles InternetTypentheorieDruckspannungBenchmarkURLVideokonferenzMultiplikationsoperatorPay-TVTouchscreenQuick-SortE-MailDifferenteUniformer RaumDokumentenserverLastGebäude <Mathematik>Registrierung <Bildverarbeitung>Web-SeiteProdukt <Mathematik>EchtzeitsystemQuellcodeSichtenkonzeptRechter WinkelWeb SiteAnnulatorDatenbankComputerspielIndexberechnungVerschiebungsoperatorBenutzerschnittstellenverwaltungssystemWeb logMomentenproblemPrototypingAutomatische HandlungsplanungBildschirmmaskeZentrische StreckungStabComputeranimation
47:08
ZahlenbereichGruppenoperationRechenwerkPROMGeradeChi-Quadrat-VerteilungÜberschallströmungGrundlagen der MathematikVektorpotenzialForcingMultiplikationsoperatorSystemplattformARM <Computerarchitektur>SystemaufrufRechter WinkelEchtzeitsystemSoftwareentwicklerGeradeReelle ZahlMereologieVollständiger VerbandSchlussregelRechenbuchWeb-SeiteMinkowski-MetrikZweiCoxeter-GruppeExpertensystemPunktFormale SpracheEin-AusgabeC sharpE-MailBenutzerbeteiligungRichtungBrowserGebäude <Mathematik>Quick-SortCodeVisualisierungInformationVerschlingungNatürliche ZahlComputeranimation
52:37
GruppenoperationZahlenbereichBildschirmfensterMereologieProjektive EbeneSystemplattformSchlussregelLeistung <Physik>SoftwaretestNamensraumSpieltheorieIntegralFramework <Informatik>Kollaboration <Informatik>Exogene VariableMehrschichten-PerzeptronGeradePerspektiveGruppenoperationMehrrechnersystemBildschirmmaskeGraphfärbungEigentliche AbbildungHypermediaFrequenzDomain <Netzwerk>MaschinenschreibenSoftwareentwicklerFunktionalEinfügungsdämpfungGesetz <Physik>ProgrammfehlerFlächentheorieApp <Programm>KomponententestCodeRuhmasseGüte der AnpassungImplementierungC sharpRechter WinkelWrapper <Programmierung>Quick-SortOffene MengeComputerschachFlächeninhaltComputeranimation
58:06
PunktwolkeDienst <Informatik>MaßstabApp <Programm>Wiederherstellung <Informatik>MehrrechnersystemComputeranimation
Transkript: Englisch(automatisch erzeugt)
00:03
Okay. Welcome to this session. I'm going to start with introducing myself. My name is Philippe. I work in making waves. I'm a developer. I'm like a backend developer and a frontend developer. A hybrid. So I do app development and applications and all that stuff.
00:23
Christopher is going to introduce himself. But before we do that, we're just going to do one thing. We're going to have a very cool demo at the end and we want to participate. So it will be like a kind of a voting contest. So please make sure you have everything ready. You have internet connection and so on. And if you want Wifi, it's NBC
00:44
2014. You may have to type that yourself. It's not that easy to find. Go ahead. Yeah. My name is Christopher. I work at making waves together with Philippe. We've been working with a company called Play Magnus. Building a game. A chess game. And so today
01:13
we're going to talk about that chess game. We're going to talk about the services behind the chess game for Play Magnus. So I want to introduce the rest of the team. That was
01:23
a part of the project. In the front area you can see Espenoidenstein. I think I lost my sound. Did I? You can hear me? Okay. It's just different. Let me see. There you go. Okay. This is Espenoidenstein. Magnus Carlsen. How many of you know Magnus Carlsen?
01:46
Yeah. A lot. That's good. He's like the world champion of chess right now. He's 23 years old. Very clever guy. This is an investor for Play Magnus. And she is working as admin for the company. And the rest area is the production team with project leaders,
02:04
a lot of people from making waves, and the rest of the team. So what we're going to talk about today is I'm going to explain a little bit about the Play Magnus app. We're going to talk about the game center or the service platform we have behind. A little
02:23
bit about the architecture and scaling of that. Philippe will talk about sharing codes in Samorin. Show some examples from Samorin and how to do things there. With that, I'm going to talk about things that we try to build on in the future. Real-time
02:42
multiplayer scenarios using WebSockets and SignalR. That's going to be a part of the demo that you participated. So what is Play Magnus? As I told you, as you saw, Magnus Carlsen was a part of the project. Play Magnus is sort of his digital brand and his
03:03
product brand. So he will, in the future, he will possibly create more products. But this is the first one. It's an iOS app now for iPhone, mainly because of the Norwegian market. Hopefully it will expand to all the different operating systems. Androids, Windows
03:25
Phone and so forth in the future. So this, yeah, I will actually leave it to Magnus himself to explain a little bit more about the app. So this is a video one minute.
03:43
And we'll take it from there. Hello, everyone. Thanks for all your support. Now that I've had a bit of time to breathe since the World Championship, I want to create something to share with the chess community.
04:00
In this app, you can spend some time getting to know me, let me teach you and challenge me to a game or two. The part I'm most excited about is that I'll be playing against winners from the app annually live at a secret location. All you have to do is download the app, sign up, and then play chess to earn points. And I very much hope that
04:25
you'll enjoy what the app holds. But I won't stop here. As we continue to develop, you will get updated training material, personal updates from me, as well as future gaming functionality, such as multiplayer and live online. I might even pop online for a game
04:45
or two. So that's sort of the concept. The main concept is the competition minus you will, if you win, you can play against minus at some point live. So let me explain just a little
05:05
bit about the app itself. You select the H. You can choose between, you can start on minus when he's five years old. Start on that level, try to beat him. You should be able to do that. Felipe will probably tell you a little bit more about that part
05:21
of the chess engine later. And up until his age today, 23 years old. And that's pretty hard. Some people have managed to do it. I'm not sure if they cheat or if they're just really clever. But it could be possible. And then we have the chess board itself. After you select it, you go into the chess game. You start playing against
05:43
Magnus. And the chess engine will actually simulate the virtual Magnus. It will play like Magnus, using his moves, using his aggressivity, his way of style of playing, his way of opening, using moves, ending games, et cetera. So it's pretty fun.
06:04
And experienced chess players also acknowledge this engine and says it's really, really the same way as playing against Magnus at times. That's really exciting. Also, Felipe will talk a little bit more about that later. So let's move on. We're
06:23
trying to find out how to build this chess engine. That's not easy. I can tell you we did this project in 11 weeks. So that says something about the timeframe here. So we did a quick Google search on chess engines just to browse what do we put into here. You can see there's a lot of things to go through in 11 weeks.
06:44
So instead, we found this guy. He's Norwegian. He's called Tore Dromsta. He's been a part of creating Stockfish, which is a very famous chess engine. So he's a really clever chess programmer, and he's a really clever chess player.
07:02
So they had a nice meeting right there. But he's been a part of the project for the whole time. He's been creating a new chess engine based on his previous work. So that's really exciting. So yeah, let's talk about the service platform behind the app. We have a lot of data
07:22
that we go through in the app. We have a list that is basically the competitions that will show you the top 100 in every list. It will aggregate some years for various levels. It will generate points. The games you played, you can look at your own stats.
07:42
And yeah, that's a lot of data we need to manage. And a lot of data is pushed in. We take care of all the games. You should be able in the future to maybe view your own games and replay them. So it's a lot of data going in and out of the system. So this was made for iOS first. We just started,
08:05
OK, what kind of game center do we use? Do we use an existing game center, or do we create a new one? So we started looking at iOS game center, but it's basically for iOS. It's very difficult to integrate Android into this game center. And it's also important for playmagnets to own their own data.
08:23
And they must be able to define competitions and lists by the need at any time. And also maintain it and use it freely within the platform. So we started to build. We have to think of a few things then. That's very important with this kind of thing.
08:43
We're talking about the global brands. Magnus Carlsen is world famous. He's within the top hundreds of most important people in the world, of young people, which has the most influence. So therefore we need to think globally at everything we do. We need to think, OK, we have a set of users.
09:03
We don't know anything about peaks. It can really be anything. Things happening in social media, things happening in normal media. So it could be Magnus Carlsen playing a chess competition, which he's doing right now in Stavanger, or on the west coast, I think.
09:21
It could be him posing with Liv Tyler on the red carpet. It could be people are sleeping in China, and then the peak goes down, right? So this will vary all the time. We have all sorts of time zones, all sorts of events that's going on. And he also wins championships, right? The World Cup.
09:45
So this was how Play Magnus was spreading after the first week. So we are talking globally very, very fast. This was after one week and all the blue countries are countries that Play Magnus would download it.
10:04
We also have to think about the global traffic latency and how they experience fetching data, putting data into the system. And we really don't want this kind of scenario. I've been there before, so I lost all my hair, as you can see, so I don't want to do this all again.
10:23
So therefore, we all experience this, right? The system is not available, you have to try again later, or you have to wait for a few seconds. We've all been buying tickets for a concert that we didn't manage to go to, and that's really a bad user experience.
10:42
So I think we should experience this. Welcome. There's a lot of people here, and we think it's great that you also want to be here with us. Right, so this is our game center. And this is in Dublin. And I'm very happy that we didn't build it and Microsoft did it instead.
11:02
So we don't have to think about those things. So scaling is quite simple, I'm going to show you just how simple it can be with these kind of solutions. But we have all sorts of power, all we need is money to run this thing. So these are the components that we currently use in Play Magnus in the game center.
11:28
Yeah, and the core component is Azure Mobile Services. How many of you heard about mobile services? Yeah, right, that's pretty good, that's good. So we do all sorts of device handling, push notifications, we have the REST API to access data.
11:46
This is a scalable component, of course. We use the Node.js version, even though you can use the Web API version now, which was released during build. And it handles everything that has to do with authentication, with Twitter, Google, Facebook and custom authentication.
12:03
So that's good. And we use all the components, I won't say too much about that. And we have other services that specialize in the various parts of the app, delivering images and photos, emails and such. Yeah, so I'm just going to skip very fast through this. This is known, this is not the real portal.
12:24
It's just an example of how mobile services looks like in Azure. You can download this for Windows Store, Windows Phone 8. It works on iOS, Androids, HTML5, Xamarin and PhoneGap. They have tutorials you can just quick start. So that's good.
12:41
This is what Scripps looks like in mobile services. It's very easy to call from C sharp and Xamarin if you want or HTML5. You can just call the connection manager, do invoke against that code. This is the name and you get the result back and you kind of form the result as you want.
13:01
So I won't go into mobile services anymore. I will talk more about scaling and the other parts of the platform. As a part of the portal you can go to the scale tab. That's relevant to this talk. And the scaling capabilities is partly decided by the kind of tier you choose for mobile services.
13:29
By choosing the standard tier you are able to auto scale from 1 to 10 instances in the portal. If you need more, if you are a big enterprise you can always talk to Azure and you can get even more.
13:44
That's basically it. Auto scaling is based on API calls. Using the standard tier you will have like 15 million API calls per unit for a month. And that is spread through the days of that month.
14:03
So then you can just go on and calculate how many instances you would probably need to get the cost of that. Alright, so the game center components is built with these services. And this is the way we try to think. There is sort of a buzz word coming up now.
14:24
That's the microservices. So we kind of think of our own system as a lot of microservices. We have the mobile service. We have a website doing some sort of things. We have Cloudinary that's handling images very well. And we have Google Storage that's also handling images very well.
14:41
So the mobile phone is talking to all these endpoints. And by doing it that way we can spread the traffic to various services instead of having a lot of load on one service. So we think this works really well for our platform. And all of these services they scale. Auto scale internally. They give us the power we need, the bandwidth and the SLA.
15:07
So if you put on more clients you kind of have this scenario where alright we need a lot of mobile services now. We need websites. We need more Cloudinary stuff. People are doing a lot of images. But it scales independently. So we don't have to worry about each instance.
15:24
As long as it's working by itself. So that's really good. And we can, I think it's very important to release some load on the parts that the mobile clients are talking to. So you could do that by putting in a notification for doing notifications instead of pushing notifications from the tier that's very close to the mobile client.
15:46
So by doing that you could probably decrease some pressure here. You could put in a service bus queue with some web workers doing long running jobs or heavy jobs. By doing that you can also decrease pressure here which will give a
16:00
better user experience from the tier that's accessed directly from the mobile phones. So that's sort of the pattern that we use when we build back in service. So let me see if this works. Yeah. There we go. Alright.
16:24
So you can also think of this through the various data centers. Maybe you need more power in Europe. Maybe you need less power in the US. Maybe you need a lot of power in East Asia. So since we have the global traffic we have to think about using multiple data centers.
16:43
And at least for the end points that the mobile phones reaches directly and you will have some centralized functionality. Flip will go into some of the ways you can do centralized functionality. Not across data centers but in a data center. Alright. So by doing scaling in Azure or mobile services, this is just an example.
17:08
You scale from day to day. So you start on one instance on day one. And when you need more API calls you go up to two and three and four instances.
17:20
So what happens then? You just pay for the instances you use at that time, at that hour and that minute. So if you have one instance for 23 hours that day you only pay for two instances for that last hour. So that's very good for every customer using Azure.
17:41
And on day two it's reset. You start on one instance again and then it builds up. So this will actually be your bill in the end. So that's the way it works. So our experience from having this microservices approach is like pros we have. You have independent scale of the various components here.
18:03
You have a great economy using the various services because they are specialized in doing the various parts. It's efficient. It feels lightweight to develop in this way. It's easy to replace a component with a different component if you want to change the provider or the service.
18:21
We can just remove that part because it's very independent. And we can choose the best service for every case. And that's based on SLA, that's based on the quality, that's based on the speed. Therefore we have excellent response, enough time on all services. And we can therefore scale based on the various peaks.
18:45
That is really unknown. It varies from day to day. And there are some concerns about this as well as developers. And that is kind of difficult to calculate the exact cost. Simply because we don't know the peaks, we don't know the pressure.
19:04
And this is something you learn during the first phase of the project. But you really have to just throw a number there. It's like what's your goal as a business? Do you want 100,000 users within a year? Then calculate what it costs to run 100,000 users.
19:23
Say they are doing 20 API calls a day. You have to create that kind of calculations to estimate the cost. And probably you won't miss too much. And then you of course need to do some sort of research on every service.
19:40
What's the SLA? What's the quality? What's the speed? How hard is it to manage this service compared to others? And there's a lot of services. And you have the challenge of decentralized management. So you have a lot of portals to log into. If not, you have a lot of scripting to do if you want to centralize it.
20:01
So you have to think of how you want to maintain this. But on the other hand, when there's a bug, if the image is not showing, you know, all right, let's go to the imaging service. So you have kind of that advantage too. So that's what I wanted to say about the Azure part.
20:21
And now Filipe is going to talk about, yeah, you can tell it themselves. Yeah, I'm going to continue with how you share code in Xamarin. We've made the iOS version first. So we haven't really, we're not done with Android.
20:41
It's a work in progress. And so is the real-time multiplayer. It's a concept. But still it's very interesting because we have already thought out how we're going to do it. And since we started doing the iOS version, we kind of, we started writing code. So we need to put it in somewhere where it could be shared. So yeah, these are the two subjects I'm going to start with.
21:03
Or I'm going to do. And just going to give you an overview of how you share code. There are various ways of doing it. You have the Xamarin components. Pretty nice way to kind of, you can download a lot of DLLs. You have their own package and you have a guarantee that they will work on various platforms.
21:23
So that's nice. You have the portable class library. I don't know how many are familiar with the portable class library. How many of you use it? Yeah, there are some, not that many, as I would expect. It's quite nice because whatever you put there, you end up with a subset. And that subset is guaranteed to work on those platforms which you selected when you created the project.
21:46
So I recommend doing that if you plan on actually targeting multiple platforms. You have the static library in C++. Maybe not many people do that or have the necessity to do that. We needed that because we wanted a test engine which was quite fast.
22:04
We had Todd on board. He is a genius and he made this quite good test engine performance. And that was in C++. But that's also a way of sharing code actually. Because you have a C++ library, you make a wrapping and you make the wrapping once and it will work on all the platforms.
22:22
So I'm going to go into that. There are new ways. I don't know if everybody heard, but Samarin 3 just came out. And it came with two cool components which is shared project. Before you had to link files, now you can use shared project. And Samarin forms is also a way to kind of draw the UI layer and have it available on all platforms.
22:46
Very powerful stuff which I am very looking forward to test out. Now, Samarin components. You can use the Samarin IDE or you can use Visual Studio.
23:01
And you will have the Samarin components available in your solution or in your project, in your UI project. So you can right click on your project and you can select edit components. And you get this nice UI where you can select components. The cool thing is that it shows, okay, so JSON.NET works on those platforms, Android and iOS.
23:23
But of course it also works on .NET. So sometimes it just doesn't show Windows, but most of you know which ones work on Windows and most of them do. And you have SQLite, you have Samarin Mobile, quite cool stuff. We used Azure Mobile Services also for authentication.
23:43
So a lot of good components. Now, they are talking about just getting rid of these and going over to NuGet. And some of them are priced. I don't know how they are going to do that with the priced ones. It will be the same principle.
24:01
Now, portable class library is something else. As I told you, you make a subset of the .NET platform and you target whatever you need to support. So in our case, we didn't need to support Silverlight, but we actually were quite ambitious and we chose everything else.
24:20
And even if you do this in Visual Studio, you can choose Xbox and we did that. But it doesn't show in the Samarin Studio. So what do we put in the portable class library? Well, of course the model. It's not that much code, but it's cool to figure out how the model will
24:41
look and how the architecture will be and just start with already there sharing the code. And from there you build your service layer. Everybody has many API calls in their app, I hope so at least. But some apps of course have a lot of big service layers and some does not.
25:03
But if you create a good service layer, you'll always end up with a lot of app validation, some exception handling, some logging, some specific exceptions. We don't have them here. This is an exception for everything. So it's a bit dirty, but we could have taken exceptions for mobile services and done more quality code here.
25:26
And you'll end up with a lot of this. So you want to put this in the portable class library, you want to make that available on all platforms and just write it once. That's quite nice. Okay, so let's say we do that and we did.
25:41
And let's say you're using Azure mobile services as we did. So you're basically doing a lot of code first because you're making the model, you're making the service layer and then you're starting using the service and it starts generating your REST API basically. So that's quite awesome. And from there it also starts generating the columns in the database because you have dynamic schema.
26:04
So that's even more awesome. Because we developers are lazy. At least I come to work like 10 maybe. Okay, just kidding. So, in app cache you also want that in your portable class library.
26:27
So, it's quite nice writing that once because in app cache can be quite easy. You can put everything in memory, you can do some custom code. We did that. And that's maybe not that much code. And if you do that on all platforms, maybe not that much work.
26:41
But you can also do more advanced stuff. You can put SQLite and you can actually make that quite a big thing. Now, I want to go back because I went a bit too fast there. Okay, so say you do an API call or you want to fetch some data but you have it in the app. So you get it from the app cache.
27:00
That's one way of releasing the load on the backend. Then let's say, well, it's not fresh data. You want to get fresher data. So you go to the mobile instance you're connected to and get it from the node cache. Node cache in this case is NPM. I think it's called node cache actually.
27:20
And you get that from the memory, from the instance instead. So you don't have to go to the database. So all of these measures are important when you're talking about an app at this global scale actually. Every little bit helps. And this looks quite nice. But it's not nice enough.
27:41
We needed more. So as we were into, you could put your SQLite in a PCL. That's quite nice. You could also share memory across various instances. So as Christopher showed you, you could use that slider and pump it up to 10 instances.
28:03
But you can share the memory between them. So you do that with Azure Cache or maybe Redis. You could use Redis if you really... That's actually quite cool. You can do calculations in memory with Redis. So that's quite awesome.
28:22
Even better, you can also use table storage if you want even more performance from your database. I'm not going to go into no SQL or SQL database debate on which one to use. But me and Christopher were kind of like, let's use both.
28:41
So that's our approach. What else can you put in a portable class library? You can put domain things. In our case, we had chess rules. You do not want to confuse chess rules with the chess engine. The chess engine is the brain. The chess rules just keeps the state of the game.
29:02
So it knows about possible moves. It knows about which moves have been done earlier, the history of the game. But it's quite a lot of code. You don't want to write that many times. And even for a clever guy like Todd, it has to be said that it was his first time writing C sharp code.
29:23
He wrote all of that in one week. But one Todd week is kind of one Felipe month. I don't think one Felipe month is that bad either. So we have that in a portable class library. That's quite nice.
29:41
We've actually used it in a website as well. That's a portable subset, you see it there. And all of the classes. The chess engine, the brain. That's a C++ library. Now, you make a static library
30:01
and you put it in your UI project, for instance. But you can't talk to C++ code just right away. How do you communicate to it? So you end up wrapping it. You end up doing interop with Mono. So we have this engine class, as you see here.
30:21
And as Christopher told you, when you play against Magnus when he's five, he's doing random moves. You see that here. I had a friend who said, oh, I beat him at five. It was super easy. There's not that much to brag about. If you do random moves yourself,
30:40
you have a 50% chance of winning. So you can send commands to our engine and it queues up. Quite cool stuff. You see here you commit the commands and you get back. But the cool stuff is, on the next slide, you can get a callback from C++ as well.
31:02
So you have a delegate and you get a callback. C++ calculates everything and you get a callback into your C sharp code. So it actually kind of invokes or calls the controller from C++, basically. So that's cool.
31:21
The move has been done. It's been calculated. You got it back and it calls the controller. And then there's some validation. I'm not going to go through all of that. But be rest assured that when everything is validated and you don't want to resign, or Magnus doesn't want to resign, you end up invoking it on the main thread
31:43
and handling it, doing either the move or handling the win if Magnus has resigned. And there's a hack. But we're not going to get into that hack. There are new ways of sharing code in Xamarin. Shared projects, instead of linking files. So you can put compiler directives
32:03
in the code inside the shared project and you differentiate which code is going to be compiled and used in the different projects. But all of this is quite nice now. It's automated much more than before you have to drag folders and do all of this manual linking.
32:21
Now it's a project which does it, pretty much the not-so-fun work for you. And there's Xamarin.Forms, which is quite awesome. Many of you probably know XAML and like to use that for layouting. And you can do that here.
32:41
So you can make a relative layout. You can say, okay, on that part I want a list view and on the bottom part I want some buttons and they are supposed to have that relative position from each other and stuff. And it actually turns out to happen on all platforms. So that's quite cool. I would look into that
33:01
if I would start writing a Xamarin app today. And there's an example in Xamarin where they made this CRM and you can register leads. I would look into that sample. Okay, so when we started the project
33:20
we had these choices to make. The way we normally do it is that we write to apps basically and we have a lot of Objective-C, we have a lot of Java. We were always going to wrap that, but the wrapper is kind of a thing in itself in different languages. So we would end up with a lot of code
33:43
which we had to write twice. At least twice, because we were also thinking about doing more platforms in the future. So a better way of doing it, as I've shown you, put it in the PCL, use C sharp, you end up using the same language everywhere.
34:03
That's an advantage. And you still have the chess engine in C++, but you only have one wrapper. So that's cool. Then if we would do this today, we would probably use a shared project and share some more UI.
34:20
We could have done MVM cross and shared some view models and stuff, but we didn't want to over-complicate things. We had people that hadn't written C sharp working in the project, so maybe using MVM cross is a kind of hardcore thing to do.
34:40
But it's also worth noting that everything here marked in green is actually testable. You test it once, everything is testable, but you test this once, and not many times. You don't need to test different codes. So on the other architecture we had, you had to test both the Java code and Objective-C. So you don't need to do that here.
35:03
So, the fun stuff. Real-time multiplayer. This is a concept we have. It's not done yet, but we've already started working on the architecture. And I'm going to just go through it because I think it's quite nice
35:21
to just get an overview of it, and it could be helpful for your projects if you're thinking about doing real-time in your apps or in VEP or whatever. This could be helpful. So, we wanted people to play against each other, multiplayer one against one,
35:41
but one against one could be solved in many ways, TCP connections one to one or something, but we wanted also to have spectators. So when this guy plays this guy, we wanted people to be able to join and look at that game in real-time. So, it was natural to kind of make a signal R-Hub
36:05
and have some test rules and a game state in the website so you can validate everything, the test rules and the game state which we already have in PCL, and just reuse that. Now I'm going to show you just
36:22
a little sneak peek. This is just a web version, just to test. I don't know if it's... Oh, white first.
36:41
Maybe it's... Hope I have internet connection. So, I just started a new game, basically. So, okay, I want to move. So, this is a real-time
37:01
multiplayer game already set up. This is cool. You could play with yourself and I'm sure I would win if I would play out this game. So, let's see. So, that's what we have in the drawing I've shown you here.
37:21
That's basically it. But there's a problem with that. It's that you'll end up wanting to have... Oh, not the pen, this one. You'll end up wanting to have various instances of these websites because it's not enough to just have one instance when you're targeting global...
37:41
You're going global. You'll probably want to have more concurrent connections. So, there's a limit on how many concurrent connections. I talked about that yesterday, but, of course, if you tweak it, you can get hundreds of thousands in one instance, in one website. But if you're kind of... You would still want to have various instances.
38:01
One instance goes down, you would still want another one to live. So, there's something missing here. There's something missing in my demo as well. There are many things, especially visually, but in back-end also. So, what you need is to have more instances. And what do you do then? Because the game states, if you just drag the slider,
38:23
you'll have a game state which doesn't know about the other game states. So, one player will be playing against, but you will not know about the other player because it's in one other instance. So, you'll have a problem. Here, you need some pub server backplane. So, we've looked into Azure service bus topic.
38:44
You can use a topic as a backplane. You publish message to the topic and you subscribe... The instances subscribe on that topic. So, if you call the topic Play Magnus topic, you'll have two subscriptions to the Play Magnus topic.
39:01
In this case, there are two instances. But if you scale to ten instances, you'll have ten subscriptions on one topic and so on. But you can also... There's also configuration to use more topics, so you can spread out the load and so on. You can use Redis for this and then you can do calculations over here,
39:21
but I don't know if that's necessary in all cases. You can also use SQL database, not that performant maybe, but more kind of a persistent. So, there are various ways of scaling out, but the cool thing about the service topic, which kind of struck me
39:40
when I started looking at it, is that it's quite easy to set up. It's much easier than one would think, at least to get started. There's always some configuration needed to get the juice out of it and performance, but just to get started, it's a lot easier than people think, probably.
40:00
If you have a website, you can do it with one line of code after installing that NuGet package. So, that's quite cool. I would probably do that. If you don't need it in a project, I would probably do that at home, just for fun. But be advised that if you stress test it and you kind of do a lot of connections to it,
40:22
you will get a pretty large bill. Yeah, so you can do it. Right now, like last week, mobile services also released this NuGet package that you just installed, and I think you get it out of the box. So then if you drag the instance counter on Azure mobile services,
40:42
you actually have a backplane, because as you see here, Azure mobile services also have signal R impregnated into the system. So, look into that as well if you're really going crazy with WebSockets. Many of us like also to use Node and Socket.IO,
41:06
and Redis is probably the most common backplane there, but you can use the service bus there as well, and there's a cool NuGet, no NPM package for that, so you put in the backplane.
41:20
But there's a bit of a difference here, because in these, I think you actually create a lot of topics. So you kind of, I think these are more sophisticated than this one, because this one just creates one topic, and you just get a lot of subscriptions on one topic. Maybe you can, you can of course configure it,
41:40
or build upon it. And also, Socket.IO came with version 1.0 just recently, so I'm not sure if this works with 1.0. I haven't tested it. Yeah, and stress testing WebSockets is important when you're going to scale a lot. So, you can use a funny NPM package called Thor,
42:05
not Thor, but Thor, which is kind of a WebSocket benchmark utility, and it's strikingly easy to get started, but it's not an enterprise test, really, but it can give you some indication of at least how you're doing in the configural sense of it,
42:23
because you, for instance, you should be able to do more than 5,000 connections on only one instance, and if you don't manage to do that, you know that something is wrong, so you can do that locally, and you can type in Thor, the amount of connections you want, and the amount of messages per connection.
42:42
And you can also, yeah, the WebSocket URL. There was a talk about the crank yesterday, or crank signalR, that's in the signalR repository. That's pretty much, it's a very sophisticated tooling to test everything in signalR, so look into that if you're going to,
43:05
like, production-wise, because you need some proper testing done. Yeah, I think we arrived at our demo. The important part here is that you go to this URL. You go to the URL,
43:21
carlson.azurewebsites.net. It's a prototype. Don't expect everything to be, there's probably some bugs, but I think actually there aren't that many, but there are probably some bugs. And you'll be met with this screen, and you'll have to, yeah, the UX here is fantastic. Either you log in at Facebook here,
43:41
or you don't have an account, and then you go over here and sign up. It's cool if you write your real email password. Importantly, most importantly, do not click on start the challenge. Then you'll be disqualified, not only from this demo, but you'll be disqualified from NDC the next 10 years.
44:03
Yeah, so put in your real email and be ready for the challenge. Just take a minute for people to get started. Yeah, to get started. So we used a lot of the components we've talked about today to make this demo. So we've probably done more than we should
44:23
for the demos case. I mean, there's a backplane, and there's a lot of things that maybe are unnecessarily technological wise, because nobody will notice it. But it was fun doing it.
44:40
This is sort of a contest. You can actually win a prize. So if you put in your email on the registration page, we will send you a prize. It's a secret. Of course, it's probably good. Not that cheap, not that cheap.
45:04
Any problems? Wow, no problems. How many are ready for the contest? Okay, so there's one. The neighbour of the guy that... How many still working to log in?
45:22
How many do not want to participate? None? Okay. We'll just wait a few more seconds. So the contest areas, you see the green button over here on your web page. Then you're ready to go. So then we will launch the contest, and hopefully everyone has internet connection,
45:40
and we have internet connection. We will see some... There will be some numbers and some updates here. What's happening here is you will get the chess challenge that you need to solve. All right, so there will be a short video explaining the chess challenge. You have to pay attention. Try to solve that chess challenge
46:00
at the most possible time. The winner is the one who has the right answer at the shortest time, okay? And when you're finished, you can take a look at what's happening on the screen. You will see some things from the other people in the audience. That's happening in real time. You will probably see what pieces they pick up,
46:25
and a little information about what's happening. We don't have that much graphical, but you'll see the points. But first pay attention to the contest. Solve that one, get it in, and then you can... We'll explain everything afterwards a little bit. So I think we're ready to go.
46:42
All right. Do you want to fire it back? Yeah, I think I managed. Mr. and Felipe, everyone at the Norwegian developer conference, I have a chess challenge for you.
47:02
Let's see if you can find the best move for white. That will checkmate black. All right, you can hit the green button and start the contest.
48:26
Someone is picking up pieces here. Done some undos?
48:42
Three seconds, you can try again. Illegal, you will be... Disqualified. It's one chance, one chance.
49:06
Here's the winner soon. On the right-hand side you can see every signal is coming in from you guys. Every piece you pick up, who's the user, the time. All right, there's five seconds left.
49:30
So this is the right answer. All right, a lot of you had that one. So probably we'll do a calculation here to see. The winner is Kristian Höklin in 13.368 seconds.
49:44
All right. Congrats. We'll get an email with information. You can come to us afterwards, just after the presentation, and we'll make sure we have the right email and there will be something for you. Great.
50:00
And it's Kentu, Daniel, Tomikris, Dallas, Benteka. You have potential, he says. So that's good. Was it fun? Yeah, cool. We did this, we can say that we did this portal on a cafe for one day, so single R is pretty easy.
50:23
It's really fun to work with. And the web part that you guys used, Filippo, doing some work before that. But it's pretty fun, and you don't need a lot of code to make this work. And using Azure, it's, yeah. The backplane is, using mobile services,
50:43
you can scale out to thousands of users, 100,000 users if you want. The backplane is automatic. So this is something you can do. And just as a short thing, maybe I heard about the browser link that just came out from Web Essentials and latest Visual Studio, if you follow Build.
51:02
That's awesome. That is sort of built on the same principle that you... In real time? Yeah, you fire up the web page and you sort of inspect it in the HTML and you can edit from the web page directly. And it syncs with Visual Studio real time.
51:22
And that is based on SignalR as well. Alright, so... Should we open up for questions? Yeah, we have some time for questions if you want. Any questions? Nothing? Alright. Not one time? Oh, here we are. Yep.
51:48
Right, so the question is, how do iOS developers or people who haven't used C Sharp before... Yeah, that's true. How they responded to using C Sharp and Xamarin.
52:02
Well, it's been sort of, since we come from the C Sharp background, it was kind of natural for us. It felt quick and easy. And we wanted an iOS specialist on the team to make sure we have the right user experience for that platform. And of course he uses Objective-C.
52:22
He's been using that all the time and is a real expert on that. But he was naturally, of course, a bit skeptical in the beginning by using a different language. And there were natural questions about, okay, do I have the full SDK and the full API to the phone? Or is it just some sort of wrapper or similar to some of the things we've seen before
52:42
from other vendors? And a lot of questions, I think. A bit of research. We had to do research ourselves to kind of explain to him from a C Sharp perspective. So a lot of collaboration going on in the beginning. But now. But now it's like super enthusiastic.
53:01
I think immediately when we deliver the project and during the project, it's by discovering the power of C Sharp and how easy it is to do complex things. He's sort of opening some doors. And he now sees the possibility to go into Windows development and to Android development in a different way.
53:22
And he has an advantage also when he kind of knows the original framework, which is based on. You have to know the namespaces. You have to know the functions you have in the phone. And those are named pretty much the same thing. But I think it's a transition that you have to go through as a new developer in any language, I think.
53:43
But then again, he just recognized the way of work and then he felt secure and confident. It's important having those platform people on board. Yeah, sure. All right. I'll repeat the question.
54:30
If I understand it correctly, you ask about testing. Yeah, Todd has his own way of testing. Just make sure we answer. Oh, repeat the question.
54:41
You want to know if testing about the C++, or do you want to know about testing of the C Sharp thing? The C Sharp thing, of course, because you have C++. Yeah, he's doing some C Sharp code. Yeah, yeah, yeah. So how would you do that?
55:00
Do you want to answer that one? Yeah, I can answer that one. Well, Todd has his own super cool way of testing. He kind of simulates things. So when he has created the framework, he simulates a lot. He sends in and actually simulates games
55:22
being played through it. And it's massive. It kind of rules out quite a lot. He puts in a lot of asserts and stuff, so there's a little testing in it. To combine. Of course, it's not kind of this C. I mean, you would use the pen detection
55:42
normally and so on. I think this test engine implementation. He is the world's best test engine developer. Probably. Yeah, that's more like an integrational test, actually. But he is like, yeah, okay,
56:01
I take the responsibility for this wrapping code in C Sharp. So it's like, you guys, you don't touch it. I'll handle it and I can ensure it's full. It doesn't have any faults. And we haven't found any bugs in it. It's like, yeah, okay, so we have to trust him. He is like the super guy in this domain, right?
56:22
But on the other part, when you talk about testing, we have tried as much as possible to create integration tests and unit tests against the PCL. And that's a good part about PCL. You can really put the PCL also in a nightly build if you want and do this automatically and kind of know about areas
56:41
before the user is actually on the phone. And I think that's part of the power behind, yeah, that's a huge power behind the PCL to be able to do that. Yeah. So that's what we tried to do with the other things than the test engine. Yeah. And also some of the code was simplified.
57:01
I removed things so it kind of doesn't look like that. Yeah. Do you have any other questions? Yeah, yeah.
57:33
You guys can go in the corner and discuss that. That's a good discussion. I think I want to join. All right. Anything else?
57:40
If not, you can always come forward to us. We'll be up here if you want to talk more about anything about the app or the code behind or, yeah, the chess engine or anything. So, yeah, that's it. Well, thanks. Thanks.
Empfehlungen
Serie mit 35 Medien