#1 2015-01-16 13:25:16

ubaltino
Member
From: Brasil
Registered: 2014-05-23
Posts: 24
Website

My Mobile Project. Doubts.

I will try to be as brief and concise as possible in this post.

Project Characteristics:
- Server: Windows Server 2012 64-bit on Amazon. Future think of migrating to Linux when mORMot is stable in this system Operacioal;
- Database: PostgreSQL 64-bit;
- Customer Mobile: mORMot Restfull with Indy. For Android and iOS. This is my biggest challenge. The performance;
- Windows Client: Only for Administration, so I'm not too concerned about performance.
- Summary Objective: There will be two types of users. Uusário seller, in this case it may have N Shops and registered their products with PHOTOS. User Buyer, which will search the app to find a product. The application should display the list of products found with the images. And if the user selects a product, should show the other photos of the product and its characteristics. That is, each product may have N PHOTOS. Also, will talk option (chat) between sellers and customers.

Points
- Parents Brazil. 3G Internet superlenta.
- Here in Brazil there is a big difference between Download and Uploud. That is, when committing (recording) data is about 70% slower.
- I'm with 80% of this application developed for the beta.
- Initially had used DataSnap + + FireDAC Restfull that comes with Delphi. This was done because until then the client version of mORMot for Mobile was not ready. Amazingly, so it was not possible to send a photo. But now with mORMot works great.
- Let's assume that within 2 years old, have 10,000 users. Being 1,000 vendors and 9,000 buyers. And that each seller has 2 stores. And each Lodge 50 products. And each product 4 photos (JPEG images).
- For photos'm reducing the image size to 160 x 160 pixels. And JPEG format.

Questions:
- If I'm doing something wrong or tm a better way, please, can speak.
- What settings should I use in mORMot server for better performance?
- Checking other similar applications, I noticed that are very fast. In fact I was impressed. I believe they are using TThread at all. Perhaps the first to raise the list of IDs, then other TThread for each ID. And then other TThread for photos of each ID. This would be the way to a good experience for the user?
- My idea would be to store photos of different sizes. Thus could select the picture size based on internet speed and size of the device screen. This would give a better experience for the user. But still can not create a function to send / receive photos (images) using TSQLRawBlob and make the necessary conversions on the server.


I miss one such example. Who worked with images for Mobile. If you can solve some points of performance, I think of and make a post here. I think that would help.

Sorry for the great post.


Ubaltino Faleiro
www.sistemainteligente.com
Brasil - Goiás - Goiânia

Offline

#2 2015-01-16 15:15:53

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,270
Website

Re: My Mobile Project. Doubts.

How are you publishing your data?
From ORM REST interface, with GET/PUT/POST/DELETE commands and blob?
This should be very fast on the server side.

I wonder if this is not the client side which is slow (Indy).
Did you try with a regular Windows client, and not Indy?

Online

#3 2015-01-16 15:30:09

ubaltino
Member
From: Brasil
Registered: 2014-05-23
Posts: 24
Website

Re: My Mobile Project. Doubts.

For reasons of simplicity in testing, I'm using only crossplatform Units mORMot. And that the same code works on Win32, Android and iOS. And of course, as you published, uses Indy in this case the client.

I have also got to think about the question of Indy be one of the causes.

And if it works fast on windows with VCL will not solve my problem, because I need to Mobile.

The example 21 uses TThread to performance tests. But think of how this would not work on Android and iOS.


Ubaltino Faleiro
www.sistemainteligente.com
Brasil - Goiás - Goiânia

Offline

#4 2015-01-16 15:55:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,270
Website

Re: My Mobile Project. Doubts.

In SynCrossPlatformSpecific.pas, try to change the following lines:

    {$ifdef UNICODE}    // for debugging Indy within the IDE
      {$define USEINDY}
    {$else}
      {$define USESYNCRT}
    {$endif}

into:

      {$define USESYNCRT}

So the application will use the TWinHttpAPI class instead of Indy under Win32.

You would be able to see if Indy is the bottleneck (as I suspect).
If Indy is really slow, we would look into another library. There are direct HTTP client units around, AFAIR.
For iOS/MacOS, we may use directly the TNSMutableURLRequest class - see e.g. https://github.com/jacobthurman/Usertil … tility.pas
Or use this unofficial Synapse port http://delphi.cz/post/Neoficialni-Synap … -2014.aspx

Online

#5 2015-01-19 17:11:34

ubaltino
Member
From: Brasil
Registered: 2014-05-23
Posts: 24
Website

Re: My Mobile Project. Doubts.

Did some testing, as recommended by you. I did not find significant differences with or without Indy Indyno Win32 and iOS.

Added 100 records with photos (images) for testing. And apparently, the biggest change is in relation the the device and Internet connection (WiFi or 3G). In my case I tested with iPhone 4 iOS version 7.1.2.

Based on this, I am more convinced that records images I read block 30. Use TThread to give a better experience for the user, ie shows the Items TListView, and then displays the images. Thus avoiding that impression that the application crashed.

Questions because I sought and found. To crossplatform (iOS and Android), in CreateAndFillPrepare function: - How to specify an order (Order By Clause)? - How could read blocks of 30 records. For example, in SQL can use rows 60 to 90?

Apparently you are using cache on the client side with SQLite3. This cache works for functions too?

Thank U


Ubaltino Faleiro
www.sistemainteligente.com
Brasil - Goiás - Goiânia

Offline

#6 2015-01-19 20:01:01

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,270
Website

Re: My Mobile Project. Doubts.

You can add an ORDER BY and a LIMIT/OFFSET clause to the constructor TSQLRecord.CreateAndFillPrepare(), in the SQLWhere parameter.

You should use the standard SQLite3 syntax.
See https://www.sqlite.org/lang_select.html#limitoffset
The ORM will then convert the SQL to the proper syntax of the database engine.

You can also set the cache on the server side.
By using the same TSQLRest.Cache class.
See http://synopse.info/files/html/Synopse% … ml#TITL_39
So it will benefit to services, also.

Please always refers to the documentation.

Online

#7 2015-01-20 19:55:33

ubaltino
Member
From: Brasil
Registered: 2014-05-23
Posts: 24
Website

Re: My Mobile Project. Doubts.

Always look the documentation. Some things crossplatform it seems they are not updated. But I know perfectly how hard it is to keep it updated.

Therefore, I have used a lot of the examples.

The issue of Cache had thought on the client side. Not the server.

I'll test your suggestions here. And since the results.

Many Thanks.


Ubaltino Faleiro
www.sistemainteligente.com
Brasil - Goiás - Goiânia

Offline

#8 2015-01-21 18:13:52

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,270
Website

Re: My Mobile Project. Doubts.

We try to do our best to have the doc updated at the same exact pace than the source code.

If you find any issue, please report them, or even better propose a patch of the documentation, since it is part of the source code tree!
smile

Online

#9 2015-01-23 12:09:12

ubaltino
Member
From: Brasil
Registered: 2014-05-23
Posts: 24
Website

Re: My Mobile Project. Doubts.

Hello ab.

From what I'm noticing the cache on the client side in crossplatform units has not yet been implemented.


Ubaltino Faleiro
www.sistemainteligente.com
Brasil - Goiás - Goiânia

Offline

#10 2015-01-23 12:21:53

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,270
Website

Re: My Mobile Project. Doubts.

Yes it is not available yet.

Online

#11 2015-02-07 10:08:25

ubaltino
Member
From: Brasil
Registered: 2014-05-23
Posts: 24
Website

Re: My Mobile Project. Doubts.

Hello ab.

I noticed that TServiceCustomAnswer has not yet been implemented in SynCrossPlatformREST.

I have an application problem freeze when read a Blob (Picture). That is not responding as it should.

This implementation TServiceCustomAnswer help.

I even looked in the other Units, to see would realize myself implement it. But still do not have the knowledge to do so.

Thank U.


Ubaltino Faleiro
www.sistemainteligente.com
Brasil - Goiás - Goiânia

Offline

#12 2015-02-07 12:37:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,270
Website

Re: My Mobile Project. Doubts.

I've created a new feature request ticket.
See http://synopse.info/fossil/tktview/bffd … e5ef2c70c3

And also fixed mORMotWrapper.pas so that it would return THttpBody for cross-platform code generation, when the function result is a TServiceCustomAnswer.
And SynCrossPlatformREST.pas so that it handles non JSON answers from the server.
See http://synopse.info/fossil/info/e3dbfa6355

Not tested yet.
Feedback is welcome.

Online

Board footer

Powered by FluxBB