A
A
arturgspb2012-08-15 12:16:13
PHP
arturgspb, 2012-08-15 12:16:13

How do you link Java + PHP?

Actually, there is a task to work with a fairly large amount of statistics, which is now in the postgresql database. Now there are about 2 million records from PK to text, and usually it is used to search for a string by a complete match. I tried varchar for speed - there was no difference at all, char - gave an imperceptible increase, and I abandoned it in favor of an unlimited field length and missing spaces at the end.

The bottom line is that queries are running slower than you want. We thought about keeping them in memory, but it’s somehow dumb if the database suddenly falls. To cache such a volume in php - I don’t think it’s normal.

We thought about using Java for HashMap for “fast” data queries (please, let’s not start “why not C / C ++”), but somehow they didn’t figure out how to organize quick communication between php and java. SOAP will probably be too slow. I read php-java-bridge.sourceforge.net/ , but there is also xml, albeit faster than SOAP.

Generally speaking, communication could be implemented somehow through Linux system functions, probably, only there is not enough knowledge how. Those. at least on sockets, probably, but to make it more or less clear what is happening in the code and it was pretty fast.

Thanks in advance to everyone who will answer how this can be done.

Answer the question

In order to leave comments, you need to log in

8 answer(s)
S
stepank, 2012-08-15
@arturgspb

zeromq?

A
Alexey Sundukov, 2012-08-15
@alekciy

>Now there are about 2 million records from PK to text, and usually it is used to search for a string by a complete match.
And how will adding a new component in the form of Java to the system solve the problem? Are there any problems at the DBMS level? EXPLAIN showed exactly that there are no problems?
It is described rather vaguely, but a purely reflector on the phrases "a lot of test data" and "search" immediately arises Sphinx.

A
Alexey Zhurbitsky, 2012-08-15
@blo

Why not use, for example, memcache to cache data from the database? And you don't have to invent anything.

O
Ogra, 2012-08-15
@Ogra

>Now there are about 2 million records from PK to text, and usually it is used to search for a string by a complete match.
Why not put in the database, say, half md5 from this line in BIGINT? There will be almost no collisions. The index as a whole will certainly work quickly, and to implement such a thing is faster than writing an additional component in Java, and even making them friends with each other.

S
shagguboy, 2012-08-15
@shagguboy

make a hash (MD5/CRC32/etc) of the text and index. and first search by this hash and then by the original.

S
Sergei Borisov, 2012-08-15
@risik

thrift

D
dborovikov, 2012-08-17
@dborovikov

Connect via http - it couldn't be easier. To transfer objects, you can take JSON as an example.

S
StrangeAttractor, 2012-08-17
@StrangeAttractor

REST

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question