SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
Realm and 
Lessons Learned building it 
{MBLT}DEV ‘14 
Brian Munkholm, 
VP Engineering @realm 
bm@realm.io 
@brianMunkholm
Menu: 
What is Realm? 
How popular? 
Why use Realm? Feedback 
Design goals & fulfilment - API examples 
Lessons Learned 
The future
What is Realm? 
• Modern mobile database - replace SQLite+ORMs 
• Easy: Object-oriented, but not an ORM 
• Safe: full ACID properties 
• Cross-platform: C++ core (3 years dev) 
• Small: compact data, object == DB (no copy!) 
• Fast 
• Free: open source!
Realm for iOS 
Used by >20,000 developers 
worldwide in < 8 weeks! 
Including ~1,000 in or very close to 
production 
>2200 GitHub Stars! 
(Parse: 10k in 8 mon)
Realm for Android 
- launched 1 month ago 
Used by >5,000 developers 
worldwide the 1’st week! 
First apps in production 
>700 GitHub Stars in 2 weeks 
(GreenDao has 1592, ORMlite 307 after years!)
Why use Realm? 
- ask the devs!
Cloth 
a beautifully designed 
personal outfit diary 
>350k users 
Uses Realm for all data 
handling 
took over a 2 year-old 
codebase and ported it to 
Realm in 1 day. 
clothapp.com 
reallyseth.com
Beanflow 
Full POS & inventory app (w/ 
offline mode) 
Uses Realm as network cache 
for all data 
“I don't have any plans to go 
back to Core Data anytime 
soon. I really like Realm.” 
sebastiandobrincu.com 
www.beanflow.com
Common benefits 
• Save time - save $$$ 
• Make faster & better apps 
• Uses less memory and disk 
• Free (de)serialisation 
• cross platform (iOS, Android, ++) 
• cross language
Design Goals 
1. Simple 
2. Fast 
3. Modern 
to learn 
to maintain 
to use across threads
1. Simple
Models 
public class Dog extends RealmObject { 
// Fields 
private String name; 
private int age; 
// + Getters and Setters… 
}
Writes 
// Obtain a Realm instance in each thread 
Realm realm = Realm.getInstance(this); 
// ACID transactions give you easy thread-safety 
realm.beginTransaction(); 
Dog dog = realm.createObject(Dog.class); 
dog.setName("Rex"); 
dog.setAge(3); 
// Full commit to disk (or memory) 
realm.commitTransaction();
RealmResults<User> teens = realm.where(User.class) 
.between("age", 13, 20) 
.findAll(); 
Queries 
// Queries can be chained efficiently 
RealmResults<User> johns = teens.where() 
.equalTo("name", “John") 
.or() 
.contains("name", “Jo") 
.findAll();
Relationships 
public class Person extends RealmObject { 
private String name; 
private Dog bestDog; // One-One relations 
private RealmList<Dog> dogs; // One-Many relations 
… 
} 
realm.beginTransaction(); 
Person person = realm.createObject(Person.class); 
person.setName("Tim"); 
person.getDogs().add(dog); 
realm.commitTransaction();
Thread-safety: All access is the same 
new AsyncTask<Void, Void, String>() { 
@Override 
protected String doInBackground(Void… voids) { 
Realm realm = Realm.getInstance(this); 
realm.beginTransaction(); 
Person person = realm.createObject(Person.class); 
person.setName("Tim"); 
realm.commitTransaction(); 
return null; 
} 
}.execute();
Thread-safety: 
• Writes cannot conflict - they block 
• No need to merge data sources, ever. 
• Reads are consistent as soon as the 
write completes
2. Fast 
BIG disclaimer! 
Use benchmarks as rough indicator 
Measure your own senarios
Lessons Learned
Lesson one 
Aim high! 
• Worlds best product 
• Solid funding from the best 
• 100% dedicated team
Lesson two 
Listen to the users / community 
• Ask users actively 
• Listen, understand their needs 
and react quickly 
• It takes time!
Lesson three 
Performance is great - but 
usability is king! 
• and eats performance… 
• Android/Java reflection is SLOW 
• but dont’ give up
Add a new object first time 
• Runtime code generation 
• Use lower level APIs 
• Compile-time code 
generation 
• Cache all the introspection 
calls 
100 
75 
50 
25 
0 
4 sec!!! 
Runtime Runtime+ Compile Time Cache
The future: 
• Encryption 
• Handover results between threads 
• Dynamic API / Migration 
• Advanced Query 
• Synchronisation 
• What do you want for xmas?
Thanks for your support!!! 
Watch or Influence? 
Feedback : 
realm.io bm@realm.io 
#Realm #BrianMunkholm

Weitere ähnliche Inhalte

Was ist angesagt?

Orleans – a “cloud native” runtime built for #azure
Orleans – a “cloud native” runtime built for #azureOrleans – a “cloud native” runtime built for #azure
Orleans – a “cloud native” runtime built for #azure
Brisebois
 
Intro Docker october 2013
Intro Docker october 2013Intro Docker october 2013
Intro Docker october 2013
dotCloud
 

Was ist angesagt? (20)

Actors Set the Stage for Project Orleans
Actors Set the Stage for Project OrleansActors Set the Stage for Project Orleans
Actors Set the Stage for Project Orleans
 
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...
 
Cohesion Techsessie Docker - Daniel Palstra
Cohesion Techsessie Docker - Daniel PalstraCohesion Techsessie Docker - Daniel Palstra
Cohesion Techsessie Docker - Daniel Palstra
 
Docker- Ha Noi - Year end 2015 party
Docker- Ha Noi - Year end 2015 partyDocker- Ha Noi - Year end 2015 party
Docker- Ha Noi - Year end 2015 party
 
ProtoPie with Electron
ProtoPie with ElectronProtoPie with Electron
ProtoPie with Electron
 
OpenWhisk Go/Swift/Binaries Runtime
OpenWhisk Go/Swift/Binaries RuntimeOpenWhisk Go/Swift/Binaries Runtime
OpenWhisk Go/Swift/Binaries Runtime
 
Actor model : A Different Concurrency Approach
Actor model : A Different Concurrency ApproachActor model : A Different Concurrency Approach
Actor model : A Different Concurrency Approach
 
Project Orleans - Actor Model framework
Project Orleans - Actor Model frameworkProject Orleans - Actor Model framework
Project Orleans - Actor Model framework
 
Democratizing Development - Scott Gress
Democratizing Development - Scott GressDemocratizing Development - Scott Gress
Democratizing Development - Scott Gress
 
Munchkin
MunchkinMunchkin
Munchkin
 
Orleans – a “cloud native” runtime built for #azure
Orleans – a “cloud native” runtime built for #azureOrleans – a “cloud native” runtime built for #azure
Orleans – a “cloud native” runtime built for #azure
 
DockerDay2015: Microsoft and Docker
DockerDay2015: Microsoft and DockerDockerDay2015: Microsoft and Docker
DockerDay2015: Microsoft and Docker
 
A Brief Intro to Microsoft Orleans
A Brief Intro to Microsoft OrleansA Brief Intro to Microsoft Orleans
A Brief Intro to Microsoft Orleans
 
Hybrid concurrency patterns
Hybrid concurrency patternsHybrid concurrency patterns
Hybrid concurrency patterns
 
ContainerDayVietnam2016: Become a Cloud-native Developer
ContainerDayVietnam2016: Become a Cloud-native DeveloperContainerDayVietnam2016: Become a Cloud-native Developer
ContainerDayVietnam2016: Become a Cloud-native Developer
 
An Automated Laser Pointer for Your Dog : Aws IoT & Lambda
An Automated Laser Pointer for Your Dog : Aws IoT & Lambda An Automated Laser Pointer for Your Dog : Aws IoT & Lambda
An Automated Laser Pointer for Your Dog : Aws IoT & Lambda
 
Intro Docker october 2013
Intro Docker october 2013Intro Docker october 2013
Intro Docker october 2013
 
Dockerizing Python Applications
Dockerizing Python ApplicationsDockerizing Python Applications
Dockerizing Python Applications
 
GoLang - Why It Matters
GoLang -  Why It MattersGoLang -  Why It Matters
GoLang - Why It Matters
 
Clouds presentation, aws meetup v2
Clouds presentation, aws meetup   v2Clouds presentation, aws meetup   v2
Clouds presentation, aws meetup v2
 

Ähnlich wie #MBLTdev: Уроки, которые мы выучили, создавая Realm

Hacking Tizen : The OS of Everything - Nullcon Goa 2015
Hacking Tizen : The OS of Everything - Nullcon Goa 2015Hacking Tizen : The OS of Everything - Nullcon Goa 2015
Hacking Tizen : The OS of Everything - Nullcon Goa 2015
Ajin Abraham
 

Ähnlich wie #MBLTdev: Уроки, которые мы выучили, создавая Realm (20)

Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
 
Introduction to Android Development and Security
Introduction to Android Development and SecurityIntroduction to Android Development and Security
Introduction to Android Development and Security
 
Celery: The Distributed Task Queue
Celery: The Distributed Task QueueCelery: The Distributed Task Queue
Celery: The Distributed Task Queue
 
Starting from scratch in 2017
Starting from scratch in 2017Starting from scratch in 2017
Starting from scratch in 2017
 
iOS Dev Happy Hour Realm - Feb 2021
iOS Dev Happy Hour Realm - Feb 2021iOS Dev Happy Hour Realm - Feb 2021
iOS Dev Happy Hour Realm - Feb 2021
 
Hacking Tizen : The OS of Everything - Nullcon Goa 2015
Hacking Tizen : The OS of Everything - Nullcon Goa 2015Hacking Tizen : The OS of Everything - Nullcon Goa 2015
Hacking Tizen : The OS of Everything - Nullcon Goa 2015
 
iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)
 
Introduction to React native
Introduction to React nativeIntroduction to React native
Introduction to React native
 
(ARC348) Seagull: How Yelp Built A System For Task Execution
(ARC348) Seagull: How Yelp Built A System For Task Execution(ARC348) Seagull: How Yelp Built A System For Task Execution
(ARC348) Seagull: How Yelp Built A System For Task Execution
 
Introduction to JAVA
Introduction to JAVAIntroduction to JAVA
Introduction to JAVA
 
Introduction to JAVA
Introduction to JAVAIntroduction to JAVA
Introduction to JAVA
 
Speedment - Reactive programming for Java8
Speedment - Reactive programming for Java8Speedment - Reactive programming for Java8
Speedment - Reactive programming for Java8
 
Introduction to Realm Mobile Platform
Introduction to Realm Mobile PlatformIntroduction to Realm Mobile Platform
Introduction to Realm Mobile Platform
 
Java days gbg online
Java days gbg onlineJava days gbg online
Java days gbg online
 
Enterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptEnterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScript
 
Scality S3 Server: Node js Meetup Presentation
Scality S3 Server: Node js Meetup PresentationScality S3 Server: Node js Meetup Presentation
Scality S3 Server: Node js Meetup Presentation
 
Building Top-Notch Androids SDKs
Building Top-Notch Androids SDKsBuilding Top-Notch Androids SDKs
Building Top-Notch Androids SDKs
 
MongoDB .local Bengaluru 2019: Realm: The Secret Sauce for Better Mobile Apps
MongoDB .local Bengaluru 2019: Realm: The Secret Sauce for Better Mobile AppsMongoDB .local Bengaluru 2019: Realm: The Secret Sauce for Better Mobile Apps
MongoDB .local Bengaluru 2019: Realm: The Secret Sauce for Better Mobile Apps
 
Mobile native-hacks
Mobile native-hacksMobile native-hacks
Mobile native-hacks
 
Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)
 

Mehr von e-Legion

Mehr von e-Legion (20)

MBLT16: Elena Rydkina, Pure
MBLT16: Elena Rydkina, PureMBLT16: Elena Rydkina, Pure
MBLT16: Elena Rydkina, Pure
 
MBLT16: Alexander Lukin, AppMetrica
MBLT16: Alexander Lukin, AppMetricaMBLT16: Alexander Lukin, AppMetrica
MBLT16: Alexander Lukin, AppMetrica
 
MBLT16: Vincent Wu, Alibaba Mobile
MBLT16: Vincent Wu, Alibaba MobileMBLT16: Vincent Wu, Alibaba Mobile
MBLT16: Vincent Wu, Alibaba Mobile
 
MBLT16: Dmitriy Geranin, Afisha Restorany
MBLT16: Dmitriy Geranin, Afisha RestoranyMBLT16: Dmitriy Geranin, Afisha Restorany
MBLT16: Dmitriy Geranin, Afisha Restorany
 
MBLT16: Marvin Liao, 500Startups
MBLT16: Marvin Liao, 500StartupsMBLT16: Marvin Liao, 500Startups
MBLT16: Marvin Liao, 500Startups
 
MBLT16: Andrey Maslak, Aviasales
MBLT16: Andrey Maslak, AviasalesMBLT16: Andrey Maslak, Aviasales
MBLT16: Andrey Maslak, Aviasales
 
MBLT16: Andrey Bakalenko, Sberbank Online
MBLT16: Andrey Bakalenko, Sberbank OnlineMBLT16: Andrey Bakalenko, Sberbank Online
MBLT16: Andrey Bakalenko, Sberbank Online
 
Rx Java architecture
Rx Java architectureRx Java architecture
Rx Java architecture
 
Rx java
Rx javaRx java
Rx java
 
MBLTDev15: Hector Zarate, Spotify
MBLTDev15: Hector Zarate, SpotifyMBLTDev15: Hector Zarate, Spotify
MBLTDev15: Hector Zarate, Spotify
 
MBLTDev15: Cesar Valiente, Wunderlist
MBLTDev15: Cesar Valiente, WunderlistMBLTDev15: Cesar Valiente, Wunderlist
MBLTDev15: Cesar Valiente, Wunderlist
 
MBLTDev15: Brigit Lyons, Soundcloud
MBLTDev15: Brigit Lyons, SoundcloudMBLTDev15: Brigit Lyons, Soundcloud
MBLTDev15: Brigit Lyons, Soundcloud
 
MBLTDev15: Egor Tolstoy, Rambler&Co
MBLTDev15: Egor Tolstoy, Rambler&CoMBLTDev15: Egor Tolstoy, Rambler&Co
MBLTDev15: Egor Tolstoy, Rambler&Co
 
MBLTDev15: Alexander Orlov, Postforpost
MBLTDev15: Alexander Orlov, PostforpostMBLTDev15: Alexander Orlov, Postforpost
MBLTDev15: Alexander Orlov, Postforpost
 
MBLTDev15: Artemiy Sobolev, Parallels
MBLTDev15: Artemiy Sobolev, ParallelsMBLTDev15: Artemiy Sobolev, Parallels
MBLTDev15: Artemiy Sobolev, Parallels
 
MBLTDev15: Alexander Dimchenko, DIT
MBLTDev15: Alexander Dimchenko, DITMBLTDev15: Alexander Dimchenko, DIT
MBLTDev15: Alexander Dimchenko, DIT
 
MBLTDev: Evgeny Lisovsky, Litres
MBLTDev: Evgeny Lisovsky, LitresMBLTDev: Evgeny Lisovsky, Litres
MBLTDev: Evgeny Lisovsky, Litres
 
MBLTDev: Alexander Dimchenko, Bright Box
MBLTDev: Alexander Dimchenko, Bright Box MBLTDev: Alexander Dimchenko, Bright Box
MBLTDev: Alexander Dimchenko, Bright Box
 
MBLTDev15: Konstantin Goldshtein, Microsoft
MBLTDev15: Konstantin Goldshtein, MicrosoftMBLTDev15: Konstantin Goldshtein, Microsoft
MBLTDev15: Konstantin Goldshtein, Microsoft
 
MBLTDev15: Anna Mikhina, Maxim Evdokimov, Tinkoff Bank
MBLTDev15: Anna Mikhina, Maxim Evdokimov, Tinkoff Bank MBLTDev15: Anna Mikhina, Maxim Evdokimov, Tinkoff Bank
MBLTDev15: Anna Mikhina, Maxim Evdokimov, Tinkoff Bank
 

Kürzlich hochgeladen

CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
anilsa9823
 
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
anilsa9823
 

Kürzlich hochgeladen (7)

CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
 
9892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x79892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x7
 
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
 
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
 
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost LoverPowerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
 
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRFULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
 
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
 

#MBLTdev: Уроки, которые мы выучили, создавая Realm

  • 1. Realm and Lessons Learned building it {MBLT}DEV ‘14 Brian Munkholm, VP Engineering @realm bm@realm.io @brianMunkholm
  • 2. Menu: What is Realm? How popular? Why use Realm? Feedback Design goals & fulfilment - API examples Lessons Learned The future
  • 3. What is Realm? • Modern mobile database - replace SQLite+ORMs • Easy: Object-oriented, but not an ORM • Safe: full ACID properties • Cross-platform: C++ core (3 years dev) • Small: compact data, object == DB (no copy!) • Fast • Free: open source!
  • 4. Realm for iOS Used by >20,000 developers worldwide in < 8 weeks! Including ~1,000 in or very close to production >2200 GitHub Stars! (Parse: 10k in 8 mon)
  • 5. Realm for Android - launched 1 month ago Used by >5,000 developers worldwide the 1’st week! First apps in production >700 GitHub Stars in 2 weeks (GreenDao has 1592, ORMlite 307 after years!)
  • 6.
  • 7. Why use Realm? - ask the devs!
  • 8.
  • 9. Cloth a beautifully designed personal outfit diary >350k users Uses Realm for all data handling took over a 2 year-old codebase and ported it to Realm in 1 day. clothapp.com reallyseth.com
  • 10. Beanflow Full POS & inventory app (w/ offline mode) Uses Realm as network cache for all data “I don't have any plans to go back to Core Data anytime soon. I really like Realm.” sebastiandobrincu.com www.beanflow.com
  • 11. Common benefits • Save time - save $$$ • Make faster & better apps • Uses less memory and disk • Free (de)serialisation • cross platform (iOS, Android, ++) • cross language
  • 12. Design Goals 1. Simple 2. Fast 3. Modern to learn to maintain to use across threads
  • 14. Models public class Dog extends RealmObject { // Fields private String name; private int age; // + Getters and Setters… }
  • 15. Writes // Obtain a Realm instance in each thread Realm realm = Realm.getInstance(this); // ACID transactions give you easy thread-safety realm.beginTransaction(); Dog dog = realm.createObject(Dog.class); dog.setName("Rex"); dog.setAge(3); // Full commit to disk (or memory) realm.commitTransaction();
  • 16. RealmResults<User> teens = realm.where(User.class) .between("age", 13, 20) .findAll(); Queries // Queries can be chained efficiently RealmResults<User> johns = teens.where() .equalTo("name", “John") .or() .contains("name", “Jo") .findAll();
  • 17. Relationships public class Person extends RealmObject { private String name; private Dog bestDog; // One-One relations private RealmList<Dog> dogs; // One-Many relations … } realm.beginTransaction(); Person person = realm.createObject(Person.class); person.setName("Tim"); person.getDogs().add(dog); realm.commitTransaction();
  • 18. Thread-safety: All access is the same new AsyncTask<Void, Void, String>() { @Override protected String doInBackground(Void… voids) { Realm realm = Realm.getInstance(this); realm.beginTransaction(); Person person = realm.createObject(Person.class); person.setName("Tim"); realm.commitTransaction(); return null; } }.execute();
  • 19. Thread-safety: • Writes cannot conflict - they block • No need to merge data sources, ever. • Reads are consistent as soon as the write completes
  • 20. 2. Fast BIG disclaimer! Use benchmarks as rough indicator Measure your own senarios
  • 21.
  • 22.
  • 24. Lesson one Aim high! • Worlds best product • Solid funding from the best • 100% dedicated team
  • 25. Lesson two Listen to the users / community • Ask users actively • Listen, understand their needs and react quickly • It takes time!
  • 26. Lesson three Performance is great - but usability is king! • and eats performance… • Android/Java reflection is SLOW • but dont’ give up
  • 27. Add a new object first time • Runtime code generation • Use lower level APIs • Compile-time code generation • Cache all the introspection calls 100 75 50 25 0 4 sec!!! Runtime Runtime+ Compile Time Cache
  • 28. The future: • Encryption • Handover results between threads • Dynamic API / Migration • Advanced Query • Synchronisation • What do you want for xmas?
  • 29. Thanks for your support!!! Watch or Influence? Feedback : realm.io bm@realm.io #Realm #BrianMunkholm