%3CLINGO-SUB%20id%3D%22lingo-sub-1067640%22%20slang%3D%22en-US%22%3EUsing%20the%20Heimdall%20Proxy%20to%20Split%20Reads%20and%20Writes%20for%20MySQL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1067640%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.heimdalldata.com%2Fmicrosoft%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3EHeimdall%20Data%3C%2FEM%3E%3C%2FA%3E%3CEM%3E%2C%E2%80%AFa%20Microsoft%20Technology%20partner%2C%26nbsp%3Boffers%20a%20database%20proxy%20to%20improve%26nbsp%3Bwrite-master%26nbsp%3B%2F%20read%20replica%20scale%26nbsp%3Bfor%26nbsp%3BSQL%20databases%20(e.g.%20MySQL%2C%20Postgres%2C%20SQL%20Server%2C%20Azure%20SQL%20Database)%26nbsp%3Bwithout%20application%20changes.%3C%2FEM%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CBR%20%2F%3E%3CSTRONG%3EBackground%3C%2FSTRONG%3E%3CBR%20%2F%3ETo%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Escale%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ethe%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Edatabase%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Etier%20efficiently%3C%2FSPAN%3E%3CSPAN%3E%2C%20database%20clusters%20are%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eoften%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eseparated%20into%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Ba%20writeable%20primary%20and%20read%20replicas.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BThis%20requires%20the%20application%20to%20route%20queries%20to%20the%20appropriate%20database%20instance.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EHowever%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%3CSPAN%3Eyou%20need%20to%20be%20mindful%20of%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%3E%3CSPAN%3Etechnical%20requirements%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%3E%3CSPAN%3E%3A%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%3ETo%20implement%20r%3C%2FSPAN%3E%3CSPAN%3Eead%2Fwrite%20spli%3C%2FSPAN%3E%3CSPAN%3Etting%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Erequire%3C%2FSPAN%3E%3CSPAN%3Es%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eexpensive%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eapplication%20code%20changes.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EThis%20can%20take%20months%20of%20development%20resources%20when%20you%20have%20better%20things%20to%20do%20with%20your%20time.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EW%3C%2FSPAN%3E%3CSPAN%3Eriting%20to%20one%20node%20and%20reading%20from%20another%20can%20result%20in%20inconsistent%20data%20due%20to%26nbsp%3B%3C%2FSPAN%3E%3CFONT%20color%3D%22%230000ff%22%3E%3CA%20href%3D%22https%3A%2F%2Fbrandur.org%2Fpostgres-reads%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ereplication%20lag%3C%2FA%3E%3C%2FFONT%3E.%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%3ESolution%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EHeimdall%20Data%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bis%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ea%20transparent%20solution%20to%20intelligently%20route%20queries%20to%20the%20most%20optimal%20data%20source%20resulting%20in%20SQL%20offload%20and%20improved%20response%20times.%20This%20includes%201)%20Routing%20queries%20to%20the%20read%2Fwrite%20instance%20while%20keeping%20data%20updated%2C%20and%202)%20Automatically%20caching%20SQL%20results.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EIn%20this%20blog%2C%20we%20will%20show%20you%20how%20to%20configure%20the%20Heimdall%20Proxy%20to%20transparently%20scale-out%20your%20write-master%20and%20read%20replicas%20for%20improved%20application%20response%20times.%20Let%E2%80%99s%20walk%20you%20through%20each%20feature.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%3EBetter%20use%20of%20Read%20Replicas%20(aka%20Read%2FWrite%26nbsp%3B%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSTRONG%3E%3CSPAN%3Esplit%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSTRONG%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22figure1.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F162195i9AE4F26298278D22%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22figure1.png%22%20alt%3D%22figure1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EFigure%201%3A%26nbsp%3BRead%2FWrite%20Architecture%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThe%20Heimdall%20proxy%20routes%20queries%20to%20the%20appropriate%20write-master%20and%20read%20replica%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bwhile%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eaccounting%20for%20replication%20lag%20and%20transactional%20state.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3ET%3C%2FSPAN%3E%3CSPAN%3Ehe%20proxy%20determines%20whether%20to%20retrieve%20the%20SQL%20results%20from%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ecache%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bor%20the%20backend%20database.%20If%20read%20query%20is%20not%20deemed%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ecachable%3C%2FSPAN%3E%3CSPAN%3E%2C%20Heimdall%20knows%20which%20read%20node%20should%20be%20accessed%2C%20query-by-query%2C%20based%20on%20what%20tables%20were%20being%20read.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ETo%20ensure%20data%20retrieved%20from%20the%20replicas%20is%20fresh%2C%20our%20proxy%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Enot%20only%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ecalculates%20the%20replication%20lag%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EThere%20are%20a%20variety%20of%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eapproaches%20to%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bread%2Fwrite%20splitting%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ebut%20they%20are%20not%20replication%20lag%20aware.%20That%20is%2C%20how%20do%20you%20know%20when%20the%20WRITE%20has%20been%20updated%20across%20all%20database%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%3Einstances%3F%20Could%20you%20be%20reading%20stale%20data%3F%20Other%20solutions%20may%20track%20lag%20but%20are%20not%20intelligent%20enough%20to%20determine%20WHEN%20it%20is%20safe%20for%20a%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eparticular%20query%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bto%20be%20routed%20to%20the%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%3CSPAN%3Eread-replica%3C%2FSPAN%3E%3CSPAN%3E%3C%2FSPAN%3E%3CSPAN%3E.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EThey%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eare%20not%20designed%20to%20fully%20offload%20the%20developer%20from%20implementing%20read%2Fwrite%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Esplit%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EIn%20Azure%2C%20Heimdall%20has%20an%20option%20to%20enable%20username%20pre-processing%2C%20to%20adjust%20the%20username%20based%20on%20the%20desired%20target%20server.%E2%80%AF%20This%20option%20is%20the%20%E2%80%9C%3C%2FSPAN%3E%3CSPAN%3EazureDbHost%3C%2FSPAN%3E%3CSPAN%3E%E2%80%9D%20setting%20in%20the%20connection%20settings%20of%20the%20data%20source.%E2%80%AF%20When%20enabled%2C%20the%20application%20uses%20a%20simple%20username%20as%20normal%2C%20but%20when%20the%20connection%20is%20made%20to%20the%20server%2C%20the%20server%20hostname%20is%20extracted%20and%20appended%20as%20%40hostname.%E2%80%AF%20This%20allows%20Azure%20managed%20databases%20to%20properly%20function%20with%20query%20routing%2C%20even%20if%20the%20application%20is%20not%20aware%20of%20this%20behavior.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ENote%3A%20Heimdall%20does%20not%20support%20data%20replication%3B%20that%20is%20the%20job%20of%20the%20database.%20Our%20proxy%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Edetects%20when%20data%20has%20completed%20replication%20and%20routes%20queries%20to%20the%20appropriate%20database%20instance.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%3ERead%2FWrite%20Split%20with%20Replication%26nbsp%3B%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSTRONG%3E%3CSPAN%3ELag%20Detection%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EEach%20query%20is%20parsed%20to%20determine%20what%20tables%20are%20associated%20with%20it.%E2%80%AF%20The%20last%20write%20time%20to%20the%20table%20is%20tracked%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eand%20is%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bsynchronized%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eacross%20proxies%3C%2FSPAN%3E%3CSPAN%3E.%E2%80%AF%20This%20provides%20the%20first%20piece%20of%20information%20(i.e.%20when%20was%20the%20last%20time%20a%20particular%20table%20was%20written%20to).%E2%80%AF%20Next%2C%20we%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ecalculate%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ehow%20long%20it%20takes%20for%20the%20writes%20to%20appear%20on%20the%20read%20instance.%E2%80%AF%20With%20this%20information%2C%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ethe%20proxy%20intelligent%20deci%3C%2FSPAN%3E%3CSPAN%3Edes%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bon%20which%20node%20is%20%E2%80%9Csafe%E2%80%9D%20to%20read%20from%E2%80%93either%20the%20read%20nodes%2C%20or%20only%20the%20write%20node.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%3EAzure%20Installation%20and%20Configuration%3A%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EStart%20the%20Heimdall%20proxy%20VM%20instance%20from%20the%E2%80%AF%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fazuremarketplace.microsoft.com%2Fen-us%2Fmarketplace%2Fapps%2Fheimdall-data.heimdall-data%3Fsrc%3Dtazure%26amp%3Btab%3DOverview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%3EAzure%20Marketplace%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E.%20The%20installation%20will%20include%20both%20the%20proxy%20and%20Central%20Console.%20For%20more%20information%2C%20visit%20our%E2%80%AF%3C%2FSPAN%3E%3CA%20href%3D%22http%3A%2F%2Fdemoa.heimdalldata.com%2Fdocs%2Fenvironment%2Fazure.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%3Etechnical%20documentation%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EOn%20the%20Heimdall%20Central%20Console%2C%20our%20configuration%20wizard%20takes%20you%20step-by-step%20to%20successfully%20connect%20the%20Heimdall%20proxy%20to%20your%20Azure%20services%20(i.e.%20application%2C%20database%2C%20cache)%2C%20and%20configure%20features%20(e.g.%20Read%2FWrite%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Esplit%3C%2FSPAN%3E%3CSPAN%3E%2C%20Caching%2C%20Load%20balancing).%20Once%20installed%2C%20on%20the%20Heimdall%20Data%20Central%2C%20click%20%E2%80%9CWizard%E2%80%9D%2C%20and%20then%20click%20%E2%80%9CManual%20Configuration%E2%80%9D%20shown%20in%20Figure%202%20below.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22clipboard_image_1.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F160944iC97A5CC15CF2EE70%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22clipboard_image_1.png%22%20alt%3D%22clipboard_image_1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EFigure%202.%20Configuration%20Wizard%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%E2%80%AF%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%3ERead%2FWrite%20splitting%20configuration%20on%20Heimdall%20Central%20Console%3A%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EAfter%20completing%20the%20Wizard%2C%20the%20configurations%20should%20be%20pre-populated.%20The%20%E2%80%9CData%20Sources%E2%80%9D%20tab%20should%20appear%20like%20below%2C%20with%20one%20read%2Fwrite%20instance%20configured%20along%20with%20at%20least%20one%20read-only%20instance%3A%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CSPAN%3EEnsure%20that%20a%20read%2Fwrite%20master%20is%20configured%20along%20with%20at%20least%20one%20read-only%20instance%3A%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%26nbsp%3B%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22clipboard_image_2.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F160943i64ADAA4405B458B3%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22clipboard_image_2.png%22%20alt%3D%22clipboard_image_2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFigure%203.%20Read%2FWrite%26nbsp%3BSplit%26nbsp%3BConfiguration%20in%20%E2%80%9CData%20Sources%E2%80%9D%20tab%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EIn%20Figure%203%2C%20since%20the%20replication%20lag%20was%20set%20to%20be%201000ms%2C%20and%20a%20table%20was%20last%20written%20two%20seconds%20(2000ms)%20ago%20would%20be%20deemed%20safe%20to%20use%20the%20read%20replica.%E2%80%AF%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EIf%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bhowever%2C%20the%20last%20write%20was%20500ms%2C%20then%20Heimdall%20would%20route%20the%20query%20to%20the%20write%20master%20node%20to%20complete%20the%20read%20operation%2C%20guaranteeing%20that%20a%20stale%20response%20was%20not%20received.%E2%80%AF%20The%20value%20of%20the%20detected%20replication%20lag%20is%20found%20on%20the%20status%20screen%20(if%20any)%3A%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22clipboard_image_3.png%22%20style%3D%22width%3A%20974px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F160946i090AD501BA950F6C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22clipboard_image_3.png%22%20alt%3D%22clipboard_image_3.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EFigure%204.%20%E2%80%9CStatus%E2%80%9D%20tab%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EFor%20further%20protection%2C%20Heimdall%20adds%20a%20fixed%20lag%20window%20value%2C%20which%20is%20configured%20in%20a%20static%20manner.%E2%80%AF%20This%20allows%20the%20replication%20lag%20window%20to%20spike%20on%20the%20short-term%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ewithout%20impacting%20the%20freshness%20of%20the%20data%20being%20returned.%E2%80%AF%20Further%20control%20over%20the%20read%2Fwrite%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Esplit%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bis%20applied%20at%20a%20rule%20level%20based%20on%20matching%20regular%20expressions%2C%20including%20bypassing%20the%20replication%20lag%20logic%20for%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eparticular%20queries%3C%2FSPAN%3E%3CSPAN%3E%2C%20and%20always%20using%20the%20read%20serv%3C%2FSPAN%3E%3CSPAN%3Eer.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22clipboard_image_4.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F160947i54AAAF5C7EB36A0A%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22clipboard_image_4.png%22%20alt%3D%22clipboard_image_4.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3BFigure%205.%20%E2%80%9CData%20Sources%E2%80%9D%20tab%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E4.%E2%80%AF%E2%80%AFIn%20the%20Rules%20tab%2C%20a%20Reader%20Eligible%20rule%20should%20be%20configured%20for%20read%20queries%20to%20be%20routed%20to%20the%20read%20server%20shown%20in%20Figure%206.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22clipboard_image_5.png%22%20style%3D%22width%3A%20985px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F160803i79F737FDB2E110E2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22clipboard_image_5.png%22%20alt%3D%22clipboard_image_5.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EFigure%206.%20%E2%80%9CRules%E2%80%9D%20tab%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EIn%20cases%20where%20the%20replication%20lag%20is%20not%20a%20concern%2C%20the%20user%20can%20create%20a%20read%2Fwrite%20split%20rule%20for%20particular%20queries%20that%20should%20unconditionally%20be%20read%20from%20the%20read%2Fwrite%20server.%E2%80%AF%20This%20may%20be%20due%20to%20a%20particular%20user%20connecting%20to%20the%20database%20as%20well%2C%20i.e.%20to%20prevent%20a%20reporting%20job%20from%20putting%20load%20on%20the%20write%20master.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%E2%80%AF%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EReal-time%20analytic%20charts%20on%20the%20Analytics%20tab%20shows%20read%20and%20write%20queries%20now%20splitting%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22clipboard_image_6.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F160950i16DCC78713C49324%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22clipboard_image_6.png%22%20alt%3D%22clipboard_image_6.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFigure%207.%20%E2%80%9CDashboard%E2%80%9D%20tab%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%E2%80%AF%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ESpecific%20query%20source%20is%20found%20in%20the%20Log%20tab%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22clipboard_image_7.png%22%20style%3D%22width%3A%20974px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F160948i7203BFF8F89C7811%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22clipboard_image_7.png%22%20alt%3D%22clipboard_image_7.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3EFigure%208.%20%E2%80%9CLog%E2%80%9D%20tab%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwp.me%2Fp7flR5-c4%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%3EQuery%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bcaching%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E%3A%20The%20second-way%20the%20Heimdall%20proxy%20is%20used%20for%20improving%20database%20scale%20is%20to%20offload%20SQL%20traffic%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bwith%20a%20look-aside%2C%20results%20cache.%20Our%20proxy%20intelligently%20determines%20which%20queries%20to%20cache%20and%20automatically%20invalidates%20when%20the%20proxy%20detects%20an%20update%20to%20the%20database.%20We%20provide%20the%20cache%20logic%20and%20you%20choose%20storage%20(e.g.%20local%20heap%2C%20Redis).%20Unique%20to%20other%20caching%20solutions%2C%20Heimdall%20can%20cache%20SQL%20results%20in%20the%20application%20tier%20removing%20unwanted%20network%20latency%20between%20the%20application%20and%20database%20as%20shown%20in%20F%3C%2FSPAN%3E%3CSPAN%3Eigure%209%20below.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22clipboard_image_0.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F161002iDC8C3DDD18966B48%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22clipboard_image_0.png%22%20alt%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EFigure%209%3A%20Heimdall%20Distributed%20Auto-caching%20Architecture%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThe%20best%20part%20of%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eour%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bcaching%20solution%20is%20its%20transparency%2C%20not%20requiring%20any%20code%20changes.%20Caching%20and%20invalidation%20are%20automated%20and%20fully%20user-configurable.%20For%20more%20information%20on%20how%20to%20configure%20Heimdall%20for%20auto-caching%2C%20check%20our%E2%80%AF%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fwp.me%2Fp7flR5-c4%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%3Eautomated%20caching%20blog%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%3ECustomer%20Benefit%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EBy%20improving%20scale%20through%20read%2Fwrite%20sp%3C%2FSPAN%3E%3CSPAN%3El%3C%2FSPAN%3E%3CSPAN%3Ei%3C%2FSPAN%3E%3CSPAN%3Etting%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Band%20SQL%20caching%2C%20queries%20will%20be%20traffic%20routed%20for%20maximum%20performance.%E2%80%AF%20Additionally%2C%20our%20proxy%20provides%20a%20bridge%20between%20a%20normal%20username%20and%20the%20hostname%20variation%20expected%20by%20Azure%20managed%20databases.%20Your%20application%20will%20operate%20seamlessly%20with%20Azure%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Edatabases%20and%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bgain%20the%20benefit%20of%20read%2Fwrite%20split.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BCustomers%20will%20save%20on%20operation%20costs%20and%20accelerate%20their%20applications%20into%20production.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%3EResources%20and%20links%3A%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fazuremarketplace.microsoft.com%2Fen-us%2Fmarketplace%2Fapps%2Fheimdall-data.heimdall-data%3Fsrc%3Dtazure%26amp%3Btab%3DOverview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%3EDownload%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ein%20Azure%20Marketplace%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EBlog%3A%E2%80%AF%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fwp.me%2Fp7flR5-c4%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAutomated%20Query%20Caching%20without%20application%20changes%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EBlog%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Database-for-MySQL%2FAccelerate-MySQL-Performance-with-the-Heimdall-Proxy%2Fba-p%2F1063349%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EHeimdall%20Proxy%20for%20Azure%20Databases%20Overview%3C%2FA%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EContact%3A%E2%80%AF%3C%2FSPAN%3E%3CA%20href%3D%22mailto%3Ainfo%40heimdalldata.com%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%3Einfo%40heimdalldata.com%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1067640%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EThe%20Heimdall%20proxy%20splits%20writes%20from%20read%20replicas%20without%20any%20application%20changes.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1067640%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Equery%20cache%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Equery%20caching%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Eread%20replica%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Eread%20write%20split%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Senior Member

Heimdall Data, a Microsoft Technology partner, offers a database proxy to improve write-master / read replica scale for SQL databases (e.g. MySQL, Postgres, SQL Server, Azure SQL Database) without application changes. 


Background
To 
scale the database tier efficiently, database clusters are often separated into a writeable primary and read replicas. This requires the application to route queries to the appropriate database instance. However, you need to be mindful of technical requirements: 

  • To implement read/write splitting requires expensive application code changes. This can take months of development resources when you have better things to do with your time. 
  • Writing to one node and reading from another can result in inconsistent data due to replication lag. 

 

Solution 

Heimdall Data is a transparent solution to intelligently route queries to the most optimal data source resulting in SQL offload and improved response times. This includes 1) Routing queries to the read/write instance while keeping data updated, and 2) Automatically caching SQL results. 

 

In this blog, we will show you how to configure the Heimdall Proxy to transparently scale-out your write-master and read replicas for improved application response times. Let’s walk you through each feature. 

 

 

Better use of Read Replicas (aka Read/Write split)

 

  figure1.png

Figure 1: Read/Write Architecture

 

The Heimdall proxy routes queries to the appropriate write-master and read replica while accounting for replication lag and transactional state. The proxy determines whether to retrieve the SQL results from cache or the backend database. If read query is not deemed cachable, Heimdall knows which read node should be accessed, query-by-query, based on what tables were being read. 

To ensure data retrieved from the replicas is fresh, our proxy not only calculates the replication lag. There are a variety of approaches to read/write splitting, but they are not replication lag aware. That is, how do you know when the WRITE has been updated across all database. instances? Could you be reading stale data? Other solutions may track lag but are not intelligent enough to determine WHEN it is safe for a particular query to be routed to the read-replicaThey are not designed to fully offload the developer from implementing read/write split. 

 

In Azure, Heimdall has an option to enable username pre-processing, to adjust the username based on the desired target server.  This option is the “azureDbHost” setting in the connection settings of the data source.  When enabled, the application uses a simple username as normal, but when the connection is made to the server, the server hostname is extracted and appended as @hostname.  This allows Azure managed databases to properly function with query routing, even if the application is not aware of this behavior. 

 

Note: Heimdall does not support data replication; that is the job of the database. Our proxy detects when data has completed replication and routes queries to the appropriate database instance. 

 

 

Read/Write Split with Replication Lag Detection 

 

Each query is parsed to determine what tables are associated with it.  The last write time to the table is tracked and is synchronized across proxies.  This provides the first piece of information (i.e. when was the last time a particular table was written to).  Next, we calculate how long it takes for the writes to appear on the read instance.  With this information, the proxy intelligent decides on which node is “safe” to read from–either the read nodes, or only the write node. 

 

 

Azure Installation and Configuration: 

 

Start the Heimdall proxy VM instance from the Azure Marketplace. The installation will include both the proxy and Central Console. For more information, visit our technical documentation. 

 

On the Heimdall Central Console, our configuration wizard takes you step-by-step to successfully connect the Heimdall proxy to your Azure services (i.e. application, database, cache), and configure features (e.g. Read/Write split, Caching, Load balancing). Once installed, on the Heimdall Data Central, click “Wizard”, and then click “Manual Configuration” shown in Figure 2 below. 

 

 clipboard_image_1.png 

 Figure 2. Configuration Wizard 

 

 

Read/Write splitting configuration on Heimdall Central Console: 

 

After completing the Wizard, the configurations should be pre-populated. The “Data Sources” tab should appear like below, with one read/write instance configured along with at least one read-only instance: 

 

  1. Ensure that a read/write master is configured along with at least one read-only instance:  

clipboard_image_2.png

 

Figure 3. Read/Write Split Configuration in “Data Sources” tab 

 

In Figure 3, since the replication lag was set to be 1000ms, and a table was last written two seconds (2000ms) ago would be deemed safe to use the read replica.  If however, the last write was 500ms, then Heimdall would route the query to the write master node to complete the read operation, guaranteeing that a stale response was not received.  The value of the detected replication lag is found on the status screen (if any): 

 clipboard_image_3.png

 

 Figure 4. “Status” tab 

 

For further protection, Heimdall adds a fixed lag window value, which is configured in a static manner.  This allows the replication lag window to spike on the short-term without impacting the freshness of the data being returned.  Further control over the read/write split is applied at a rule level based on matching regular expressions, including bypassing the replication lag logic for particular queries, and always using the read server. 

 

 clipboard_image_4.png

 

 Figure 5. “Data Sources” tab 

 

 

4.  In the Rules tab, a Reader Eligible rule should be configured for read queries to be routed to the read server shown in Figure 6. 

  clipboard_image_5.png

 

 Figure 6. “Rules” tab 

 

 

In cases where the replication lag is not a concern, the user can create a read/write split rule for particular queries that should unconditionally be read from the read/write server.  This may be due to a particular user connecting to the database as well, i.e. to prevent a reporting job from putting load on the write master. 

  

Real-time analytic charts on the Analytics tab shows read and write queries now splitting:

clipboard_image_6.png

 

Figure 7. “Dashboard” tab 

 

 

Specific query source is found in the Log tab:

 clipboard_image_7.png

 

Figure 8. “Log” tab 

 

 

Query caching: The second-way the Heimdall proxy is used for improving database scale is to offload SQL traffic with a look-aside, results cache. Our proxy intelligently determines which queries to cache and automatically invalidates when the proxy detects an update to the database. We provide the cache logic and you choose storage (e.g. local heap, Redis). Unique to other caching solutions, Heimdall can cache SQL results in the application tier removing unwanted network latency between the application and database as shown in Figure 9 below.

 clipboard_image_0.png

 

Figure 9: Heimdall Distributed Auto-caching Architecture 

 

The best part of our caching solution is its transparency, not requiring any code changes. Caching and invalidation are automated and fully user-configurable. For more information on how to configure Heimdall for auto-caching, check our automated caching blog. 

 

 

Customer Benefit 

 

By improving scale through read/write splitting and SQL caching, queries will be traffic routed for maximum performance.  Additionally, our proxy provides a bridge between a normal username and the hostname variation expected by Azure managed databases. Your application will operate seamlessly with Azure databases and gain the benefit of read/write split. Customers will save on operation costs and accelerate their applications into production. 

 

Resources and links: